daily pastebin goal
2%
SHARE
TWEET

Untitled

a guest Aug 21st, 2018 62 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. Removing the class name before calling a custom function?
  2. public class Class1
  3. {
  4.     public static string UppercaseFirst(string s)
  5.     {
  6.         // Check for empty string.
  7.         if (string.IsNullOrEmpty(s))
  8.         {
  9.             return string.Empty;
  10.         }
  11.         // Return char and concat substring.
  12.         return char.ToUpper(s[0]) + s.Substring(1).ToLower();
  13.     }
  14. }
  15.    
  16. string MyName = "john";
  17. string result = Class1.UppercaseFirst(MyName)
  18.  
  19. Result: "John"
  20.    
  21. public static string UppercaseFirst(this string s)
  22.     {...
  23.    
  24. public static class StringExtension
  25. {
  26.   public static string UppercaseFirst(this string text)
  27.   {
  28.     // ..
  29.   }
  30. }
  31.    
  32. string uppercase = "myText".UppercaseFirst();
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top