相关疑难解决方法(0)

c#将struct转换为另一个struct

有什么办法,如何转换这个:

namespace Library
{
    public struct Content
    {
        int a;
        int b;
    }
}
Run Code Online (Sandbox Code Playgroud)

我在Library2.Content中有结构,其数据定义方式相同({ int a; int b; }),但方法不同.

有没有办法将struct实例从Library.Content转换为Library2.Content?就像是:

Library.Content c1 = new Library.Content(10, 11);
Library2.Content c2 = (Libary2.Content)(c1); //this doesn't work
Run Code Online (Sandbox Code Playgroud)

c# struct

5
推荐指数
3
解决办法
7609
查看次数

标签 统计

c# ×1

struct ×1