H
Harvey Triana
Hello.
By example, I have string with a "Hello There". I use Right("Hello There",
3) function in VB.NET to just get "ere" out of the string but there doesn't
seem to be one in C#.
I have two approach:
1) write something as:
public static string Right(string s, int n) {
if (n > s.Length) {
return s;
}
else if (n < 1) {
return "";
}
else {
return s.Substring(s.Length - n, n);
}
}
.. and put then into library
2) Use Microsoft.VisualBasic namespace into C# application. .. (to be C is
not seen elegant)
My quiestion is: -
Which approach do you prefer?
Which approach has better performance?
<Harvey Triana />
By example, I have string with a "Hello There". I use Right("Hello There",
3) function in VB.NET to just get "ere" out of the string but there doesn't
seem to be one in C#.
I have two approach:
1) write something as:
public static string Right(string s, int n) {
if (n > s.Length) {
return s;
}
else if (n < 1) {
return "";
}
else {
return s.Substring(s.Length - n, n);
}
}
.. and put then into library
2) Use Microsoft.VisualBasic namespace into C# application. .. (to be C is
not seen elegant)
My quiestion is: -
Which approach do you prefer?
Which approach has better performance?
<Harvey Triana />