Attention: We are retiring the ASP.NET Community Blogs. Learn more >

The great Right to Left assignment debate :-)

There's a conversation occuring on serveral other blogs about the validity of statements that assign to multiple variables in a right to left manner.  Methinks that a few people are confusing C# with VB :-) - oh well, at least I get to show off the amazing powers of the MarkItUp component again ;)  - http://www.markitup.com/Client/MarkItUpNew.asp

This is just one of the cool things that I wish VB  had!  <shrug /> I suppose no language is perfect given that they didn't allow for fall-through in switch statements for C#!

*************

 /// <summary>
 /// Right to left assignment.
 /// </summary>
 public class WebForm1 : System.Web.UI.Page
 {
  private void Page_Load(object sender, System.EventArgs e)
  {
    string a,b,c ;
    a=b=c="Hello" ;
    Response.Write("a: " + a + "<br>") ;
    Response.Write("b: " + b + "<br>") ;
    Response.Write("c: " + c + "<br>") ;
            
    int g,h,i ;
    g=h=i=101 ;
    Response.Write("g: " + g + "<br>") ;
    Response.Write("h: " + h + "<br>") ;
    Response.Write("i: " + i + "<br>") ;

    bool l,m,n ;
    l=m=n=true ;
    Response.Write("l: " + l + "<br>") ;
    Response.Write("m: " + m + "<br>") ;
    Response.Write("n: " + n + "<br>") ;
  }

No Comments