问题描述
你好,
我有一个解决方案,其中包含一个名为"one"的文件夹,其中包含一个名为project.cs的.cs文件,我有一个字符串值,即字符串msg ="Hello"
同样的解决方案我有一个Form1.cs表单,我需要在其中拆分字符串并在datagrid中显示,但是为此,我需要在form1中获取字符串值msg?该怎么做?
即使我说一个.味精我也看不到味精intilesense.
我应该设定并获得财产吗?
在此先感谢
Hello,
I have a solution which consist of a folder called ''one'' which has a a .cs file called project.cs, I have a string value hear which is say string msg="Hello"
Same solution I have a form Form1.cs where I need to split the string and show in datagrid,but for that I need to get the string value msg in form1?How to do that?
even if i say one.msg i dont see msg intilesense.
Should i set and get as a property ?
Thanks in advance
推荐答案
cls_a obja = new cls_a();
string[] strArr = obja.msg.toString().split('l');
namespace one
{
class project
{
public string msg { get; set; }
}
}
并会喜欢它
and would refer to it liek this
<br />
one.project.msg
.
希望这对您有帮助
.
Hope this helps
public string msg { get; set; }
这将创建msg
字符串作为类级别的公共属性.
2)在Form1中,声明项目类的实例,然后可以访问它的msg
属性.
This creates the msg
string as a class level public property.
2) In Form1, declare an instance of the project class, and you can access it''s msg
property.
project myProject = new project();
myProject.msg = "Hello";
在这里,您仍然需要更改一些命名约定(类应以大写字母开头,因此应为Project
而不是project
,属性相同,再加上全名,而不是缩写:Message
而不是msg
,但这应该可以帮助您入门.
There are still a few things here you should change as far as naming conventions go (Classes should start with a Capital Letter, so it should be Project
not project
, Properties the same, plus they should have full names, rather than abreviations: Message
rather than msg
, but this should get you started.
这篇关于从另一个文件夹获取数据相同的解决方案的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!