this Keyword C# with Example



this Keyword C# with Example

 		using System;

		namespace CSharpClass{
		class Watch
		{
			public byte hour{set; get;}	
			public byte minute{set; get;}
			
			public Watch(byte hour, byte minute)
			{
				hour = hour;
				minute = minute;
			}
			
			public void DisplayTime()
			{
				Console.WriteLine(hour + ":" + minute);
			}
		}
			
			class UsingWatchConstructor{
				static void Main(String[] arg){
					Watch sonata = new Watch(10, 12);
					Console.Write("Time of the Sonata Watch is: ");
					sonata.DisplayTime();
				}
			}
		}
 

0 Comment's

Comment Form

Submit Comment