当前位置:首页 > 开发 > C# > 正文内容

C# 结构体struct 例子

C#3年前 (2022-10-23)
/// <summary>
/// 结构体
/// </summary>
struct MyStruct
{
    public string Name;
    public int Age;
}
static void Main(string[] args)
{
    MyStruct myStruct = new MyStruct();
    myStruct.Name = "无尽的华尔兹";
    myStruct.Age = 25;
    Console.WriteLine(myStruct.Name);
    Console.WriteLine(myStruct.Age);
    Console.Read();
}


转载请注明出处。

本文链接:http://www.pythonopen.com/?id=221

相关文章

C# for,while,do while,switch

for    #region for for ...

C# 将函数作为参数传递

无参数    static void Main(s...

在 C# 中实现类似于 Windows 资源管理器的“名称”排序方式

要在 C# 中实现类似于 Windows 资源管理器的“名称”排序方式,你需要考虑以下几点:1. 不...

C# 可空参数

using System; using System.Runtime.Inte...

C# Browsable(bool)

在编程中(比如常见的 C# 语言在开发 Windows Forms 等应用程序时),Browsabl...

C# Byte[]转为Image

以下是在 C# 中将byte[](字节数组,通常表示图像的二进制数据)转换为Image类型的常见方法...