Analysis of usage examples of C# Class
Most people do not understand the knowledge points of this "C# class use case analysis" article, so the editor summarizes the following content, detailed content, clear steps, and has a certain reference value. I hope you can get something after reading this article. Let's take a look at this "C# class use case analysis" article.
Example
Using System
Namespace BoxApplication
{
Class Box
{
Public double length; / / length
Public double breadth; / / width
Public double height; / / height
}
Class Boxtester
{
Static void Main (string [] args)
{
Box Box1 = new Box (); / / declare Box1 with type Box
Box Box2 = new Box (); / / declare Box2 with type Box
Double volume = 0; / / Volume
/ / Box1 details
Box1.height = 5.0
Box1.length = 6. 0
Box1.breadth = 7. 0
/ / Box2 details
Box2.height = 10.0
Box2.length = 12.0
Box2.breadth = 13.0
/ / Volume of Box1
Volume = Box1.height * Box1.length * Box1.breadth
Console.WriteLine ("volume of Box1: {0}", volume)
/ / Volume of Box2
Volume = Box2.height * Box2.length * Box2.breadth
Console.WriteLine ("volume of Box2: {0}", volume)
Console.ReadKey ()
}
}
}
When the above code is compiled and executed, it produces the following results:
The volume of Box1: the volume of 210Box2: more than 1560 is about the content of "C# class use case analysis". I believe we all have a certain understanding. I hope the content shared by the editor will be helpful to you. If you want to know more about the relevant knowledge, please pay attention to the industry information channel.