Showing posts with label c# - string method. Show all posts
Showing posts with label c# - string method. Show all posts

Friday, July 22, 2022

c# - How convert string array into one string

If you use this code on string array:
string[] args = Environment.GetCommandLineArgs();      
Console.Write( args.ToString() );
you will get:
System.String[]
But better way in this case is to use string.Join() function (where you can set used delimiter):
string[] args = Environment.GetCommandLineArgs();      
Console.Write( string.Join( ",", args ) );
Then:
C:\app.dll,layoutdir=C:/app/bin

Friday, January 3, 2020

C# - How to convert first character of string to upper letter

The problem is little complicated, because access to string chars (through indexer) is only read-only.
One way is this:

row.Constellation = arr[2].Trim().ToLower();
char[] ch = row.Constellation.ToCharArray();
ch[0] = char.ToUpper( row.Constellation[0] );
row.Constellation = new string( ch );