英文:
how does a class as a data type or return type works. Can some one please tell,
问题
public class ClassName {
int number;
String name;
public ClassName(int d) { // 这个方法会返回什么??
d = 10 ;
name = "ABC";
}
}
我无法理解类作为数据类型或返回类型时是如何工作的。有人可以告诉我,展示给我,或者教教我它是如何工作的吗?
英文:
public class className{
int number;
string name;
public ClassName(int d) { //What will return from this method??
d = 10 ;
name = "ABC";
}
}
I cant figure out how does a class as a data type or return type works. Can some one please tell, show or teach me how it works.
答案1
得分: 0
类似于自定义数据类型的概念。
我们有字符串,表示单词。
我们有整数,表示整数。
并没有原生的节点数据类型,你希望它具有数据和下一个属性。
当你像使用其他任何数据类型一样传递Node类时,将会有关于节点数据和节点下一个的信息,而不仅仅是字符串或整数。
英文:
Think of a class as a custom datatype.
We have strings, which represent words.
We have ints, which represent whole numbers.
There is no native datatype for Node, which you want to have a data and next property.
As you pass the Node class like you would any other datatype, but will have information on the Node data and Node next, not just a string or int.
答案2
得分: 0
你可能需要阅读关于C#和.NET类型系统的内容,文档是一个很好的起点。
英文:
You might need to read about The C# and .NET type system, the docs is a good place to start.
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论