部分结构分为.dll和local.cs [英] Partial struct divided into a .dll and a local.cs

查看:110
本文介绍了部分结构分为.dll和local.cs的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

 In WPF with C# i use a partial structure that happened as a parameter in many functions. A part of the structure is in the Comun.cs file that is compiled in Comun.dll and contains general variables to all the programs.

The other part of the partial structure is in a Local.cs file and contains variables specific to each program. I have put this file in App_Data.


When compiling with VS, in the places where i refer to the Local.cs variables, the program tells me that the variables are not recognized. I need to be able to compile the final program so that it recognizes all the variables.I have read that there is a partial interface but I do not know if it is useful for this.

Comun.cs -> Comun.dll

public partial struct St_Gen

{   public int Languaje;

}

 

Local.cs

public partial struct St_Gen

{   public int LocalVariable;

}

2.- Another problem is that I can not find the documentation on the structure of the WPF directories. Ex: App_Data what is it for ...

3.- another problem is that it is difficult to find code from other developers in WPF. ¿why? ¿Do you know any site besides codeproject?

4.- Why are there no examples of current WPF codes? Almost all are old.

5.- Working in C # What is more advanced than WPF?

Thanks





我尝试过:





What I have tried:

What have you tried?

What have you tried?

推荐答案

部分关键字允许您跨多个文件传播内容,但...仅在同一命名空间内,并且仅在编译时 - 你不能使用 partial 从定义的程序集外部扩展一个结构。



无法以您希望的方式将变量添加到 struct 。 (并且你根本不能从 struct 继承,因此你无法派生新的 struct 或<来自他们的code> class 。



想想你想要做什么:可能有很多,很多更好的方法!
The partial keyword allows you to spread content across multiple files, but ... only within the same namespace, and only at compile time - you cannot use partial to "extend" a struct from outside the assembly it is defined in.

It is not possible to "add" variables to a struct in the way you want. (And you can't inherit from a struct at all, so you can't derive a new struct or class from them either.)

Think about what you are trying to do: there is probably a much, much better way to do it!


Is it not possible in some way using partial interface?

Why it is not allowed to pass as a parameter ref dynamic?

Can someone answer the other questions I ask? Is WPF a good system or should I move on to something better (with c#)? Thank you


这篇关于部分结构分为.dll和local.cs的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆