您能协助改善这门课吗? [英] Can you assist to improve this class please?

查看:123
本文介绍了您能协助改善这门课吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一堂课-表演.
由田野制成-学术,物理学,社会学.

I have a class - Performance.
Made of Fields - Acadamics, Physic, Socials.

class Performance
{
    public string Acadamic {get; set;}
    public string Physical {get; set;}
    public string Socials {get; set;}
}



在我的表格上:
性能p =新Performance();
字符串s = p.Acadamics;

它是完美的,但我想将考试,CA,学期等作为子字段或参数包括在内,以进行以下操作:

p.Acadamics.CA.Semester;
甚至更进一步.
我该怎么办?
谢谢.



On my Form:
Performance p = new Performance();
String s = p.Acadamics;

Its perfect but I want to include Exams, CA, Semesters, etc, as sub Fields or parameters to proceed to:

p.Acadamics.CA.Semester;
or even further.
How do I go about it please?
Thank you.

推荐答案

你好Salisu,
考试,CA和学期不能称为参数,而应该是另一组课程的属性.

就像在一个层次结构中一样.
实例,
表演是主要课程,其中包括学术榜单,物理榜单,社会榜单.
然后学者将是具有CA和Exams要求的属性的另一门课.然后,只有您才能调用查询中提到的层次结构中的属性.
如果我对您的查询的预期是正确的,希望您能理解我的意思.
如果有疑问,请发回您的查询.
谢谢
Hello Salisu,
The Exams, CA & Semesters can''t be called parameters, they would rather be the properties of another set of class.

Like in a heirarchy.
FOr instance,
Performance is the main class that would contain List of Academics, List of Physics, List of Socials.
Then Academics would be another class with the properties required like CA and Exams may be. Then only you can invoke the properties in heirarchy as you have mentioned in your query.
I hope you understand what I say, if my anticipation was correct on your query.
Please post back your queries if any.
Thanks


第一件事是编程总是要为您的系统做一个良好的草图,为此您将为其编写应用程序,或者至少为其编写逻辑.

就您而言,这似乎更像是一个用来保存学生总体成绩的学院系统.在这种情况下,您应该将重点重点放在学生本人上,而这些其他班级一定不能属于string数据类型,而必须属于他们自己班级的数据类型.这样的,

First thing is programming is always to make a good sketch of your system, for which you''re going to write the application for, or atleast the logic for.

In your case, which seems more like an institute''s system to save the student''s overall performance. In that case, you should move importantly focus on the student himself and these other classes must not be of string data type but of their own class''s data type. Such as this one,

class Performance
{
    public Academic Academic {get; set;}
    public Physical Physical {get; set;}
    public Socials Socials {get; set;}
}



..现在要使其工作,必须为它们提供相应的类以控制所传递的数据,例如



.. now to make them work, you must have corresponding classes for them to control the data being passed, like this maybe,

class Academic {
   public string static Course {get; set}
   public string static Semester {get; set;}
   // other properties here
}



您可以像上面一样建立另外两个类(物理类和社会类),以在其中保存自己的数据.这样,您可以定义类和对象以在其中包含相关数据.现在,您将知道在调用属性时,可以像
那样调用它们



You can build other two classes, (Physical and Socials) like above one that would hold their own data in them. In this way, you can define the classes and objects to contain the related data in them. Now, you would know that when you''re going to call the properties, you would be able to call them like,

Performance performance = new Performance();
performance.Academic.Course; // because Course is a static field



但这不会让您访问Semester字段,因为会出现一个错误,说字符串"不包含"Semester"的任何定义.这是合法的,因为Semester不是 System.String [ ^ ]或string.

我真的很想建议您首先开始学习如何使用C#语言,以及什么是对象以及如何从代码中调用这些属性.然后,您将能够理解这些功能,并可能通过每个成员返回一个对象来创建长查询,该对象将允许调用下一个成员,依此类推.

还有一件事,我确实注意到,在您的标识符中,对于被调用的成员以及该类内部的成员,存在歧义.编写名称时,您不应使用任何错字,C#是区分大小写和区分字母的语言.标识符和成员的名称必须匹配才能按原样进行编译,源代码甚至无法编译.

祝你好运!



But it won''t let you access the Semester field, because there will be an error saying, "string" doesn''t contain any definition of "Semester". That is legit, because Semester is not a property or member of System.String[^] or string.

I really would like to recommend that you first of all, start to learn how to use the C# language, and what are objects and how to call these properties from the code. Then you will be able to understand these features and might be able to create a long query by each member returning an object that would allow the next member to be called and so on and so forth.

One more thing, I did notice that there was an ambiguity in your identifiers for members being called and inside the class. You should not use any typos while writing the names, C# is a case-sensitive and letter-sensitive language. Names of the identifiers and members must match in order to compile as it is, the source code won''t even compile.

Good luck!


这篇关于您能协助改善这门课吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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