Change string using ref keyword : Ref : Language Basics C# Examples


C# Examples » Language Basics » Ref »

 

Change string using ref keyword









    
using  System;

class  MainClass
{
    public  static  void  UpperCaseThisString(ref  string  s)
    {
        s  =  s.ToUpper();
    }
    public  static  void  Main()  
    {
        string  s  =  "str";
        Console.WriteLine("->  Before:  {0}",  s);
        UpperCaseThisString(ref  s);
        Console.WriteLine("->  After:  {0}\n",  s);
    }
}
    
   
  
   



Output

-> Before: str
-> After: STR


HTML code for linking to this page:

Follow Navioo On Twitter

C# Examples

 Navioo Language Basics
» Ref