Get the App
SLTechnology News&Howtos  ›  Development  › 

Analysis of usage examples of C# Class

Shulou Source: shulou.com Published: 2022-06-01 02:00:45 09月12日 Update

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.

Tags: Volume content example case analysis analysis article knowledge article type code value most width that is more steps knowledge points results industry Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno Linux vpn Shulou Tech Info MySQL Huawei