1

Hi is there a way to convert the java string format to c#? I want to code in c# but I don't know how I can translate this java CODE:

String credentials = String.format("%s:%s", param1, param2);

I have already tried to translate it to c# but it doesn't work for me here is my c# code:

string credentials = string.Format("%s:%s", param1, param2);

1 Answer 1

2

You can use string interpolation (more at $ - string interpolation (C# reference)):

string credentials = $"{param1}:{param2}";

Otherwise it's composite formatting with indexes (see Composite formatting):

string.Format("{0}:{1}", param1, param2);
Sign up to request clarification or add additional context in comments.

1 Comment

or just string credentials = param1 + ":" + param2;

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.