out modifier requires that a variable is assigned a value before returning from a method
using System; class Test { static void Split(string name, out string firstNames, out string lastName) { int i = name.LastIndexOf(' '); firstNames = name.Substring(0, i); lastName = name.Substring(i+1); } static void Main( ) { string a, b; Split("Sachin Tendulkar", out a, out b); Console.WriteLine("FirstName:{0}, LastName:{1}", a, b); } }
No comments:
Post a Comment