Monday, August 22, 2011

simple ref example

doubling 7 to 14 ...will end up in ViewBag.Message given the code below:

public ActionResult Index()

{

   Int32 myNumber = 7;

   ViewBag.Message = DoubleNumber(ref myNumber) + " to " + myNumber;

   return View();

}

   

public string DoubleNumber(ref Int32 growable)

{

   string act = "doubling " + growable;

   growable = growable*2;

   return act;

}

No comments:

Post a Comment