substring in Java to Substring in C# -
substring in Java to Substring in C# -
i have 2 substring statements in java need convert c#. first of seems working, 2nd not much , don't know why.
the key string of variable length 7-18 characters
first 1 in java , in c#. x can 1-12 characters.
string x = key.substring(0,key.length()-6); system.out.println("\nx: " + x.touppercase()); console.writeline ("\ndln: " + (key.substring (0, key.length - 6).toupper ()));
2nd one, y 1st 2 characters after x
string y = key.substring(key.length()-6, key.length()-4); system.out.println("\ny : " + y.touppercase()); //not working console.writeline("\ny: " + (key.substring(key.length -6, key.length -4)).toupper ());
the sec argument of substring
not index of lastly character want, it's number of characters want.
so, if want first 2 characters after x
, utilize count of 2.
key.substring(key.length -6, length: 2)
java c# substring
Comments
Post a Comment