Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Removing the class name before calling a custom function?
- public class Class1
- {
- public static string UppercaseFirst(string s)
- {
- // Check for empty string.
- if (string.IsNullOrEmpty(s))
- {
- return string.Empty;
- }
- // Return char and concat substring.
- return char.ToUpper(s[0]) + s.Substring(1).ToLower();
- }
- }
- string MyName = "john";
- string result = Class1.UppercaseFirst(MyName)
- Result: "John"
- public static string UppercaseFirst(this string s)
- {...
- public static class StringExtension
- {
- public static string UppercaseFirst(this string text)
- {
- // ..
- }
- }
- string uppercase = "myText".UppercaseFirst();
Add Comment
Please, Sign In to add comment