由买买提看人间百态

boards

本页内容为未名空间相应帖子的节选和存档,一周内的贴子最多显示50字,超过一周显示500字 访问原贴
DotNet版 - Question about struct
相关主题
Can a struct be derived? in C#, in C++问一个Array Sort的问题
A permission problem?大牛指教:新手List<>问题
Named Parametersvb.net event handler 请教!如何raise一个event,所有form中任何一个on top的可以handle?
C# interview question问个问题
how to use Ping() class?About memory usage of .Net program
Kill running applicationsVB.Net question
请问可能从command line invoke复杂的Windows Form Application吗?xmldocument and webservice question
用Web Service,当client调用Server的API的时候, 谁熟dotnet 的webservice?
相关话题的讨论汇总
话题: struct话题: mystruct话题: parameter话题: question
进入DotNet版参与讨论
1 (共1页)
s*******k
发帖数: 20
1
[quote]Within an instance constructor of a struct, "this" corresponds to an
out parameter of the struct type, and within an instance function member of a
struct, "this" corresponds to a ref parameter of the struct type. In both
cases, this is classified as a variable, and it is possible to modify the
entire struct for which the function member was invoked by assigning to "this"
or by passing this as a ref or out parameter.[/quote]
Not quite get it.
Would any DX help with some intances?
Thanks.
k****i
发帖数: 1072
2
struct MyStruct
{
int x, y;
public MyStruct(int x, int y)
{
this.x = x;
this.y = y;
}
public void Change()
{
this=new MyStruct(1,1);
Print();
}
public void Print()
{
System.Console.WriteLine(this.x);
}
}
Remember, "this" is a value in class

a
this"

【在 s*******k 的大作中提到】
: [quote]Within an instance constructor of a struct, "this" corresponds to an
: out parameter of the struct type, and within an instance function member of a
: struct, "this" corresponds to a ref parameter of the struct type. In both
: cases, this is classified as a variable, and it is possible to modify the
: entire struct for which the function member was invoked by assigning to "this"
: or by passing this as a ref or out parameter.[/quote]
: Not quite get it.
: Would any DX help with some intances?
: Thanks.

w**w
发帖数: 5391
3
can you explain how to know this in class is a value type?

【在 k****i 的大作中提到】
: struct MyStruct
: {
: int x, y;
: public MyStruct(int x, int y)
: {
: this.x = x;
: this.y = y;
: }
: public void Change()
: {

s*******k
发帖数: 20
4
My understanding is:
"this" in class is a value, not a variable; while in struct, it is a variable,
which represents a storage location, mostly likely the containing variable
itself.
Am I right?
Further question regarding "this is a value in class": What is the value of
this in class then?

【在 w**w 的大作中提到】
: can you explain how to know this in class is a value type?
1 (共1页)
进入DotNet版参与讨论
相关主题
谁熟dotnet 的webservice?how to use Ping() class?
NHiberniate Custom Class LibraryKill running applications
How to open a local HTML file with parameters in the default browser in vb.net?请问可能从command line invoke复杂的Windows Form Application吗?
拷。.net有个重大bug用Web Service,当client调用Server的API的时候,
Can a struct be derived? in C#, in C++问一个Array Sort的问题
A permission problem?大牛指教:新手List<>问题
Named Parametersvb.net event handler 请教!如何raise一个event,所有form中任何一个on top的可以handle?
C# interview question问个问题
相关话题的讨论汇总
话题: struct话题: mystruct话题: parameter话题: question