本文介绍了班级......为什么这不起作用?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述 29岁程序员,3月因学历无情被辞! 您好, 我有以下课程: 名称空间MyApp.Models { 公共课领带{ 公开计数{get;组; } public Tie(){ this.Count = new Count(); } } } 名称空间MyApp.Models { 公共班计数 { public int File {get;组; } public int教授{get;组; } } } 但是,当我在我的代码中访问Tie类时,只能想到Visual 工作室认可的是: Tie.Tie.Tie ... 为什么我不能访问Tie.Count? Tie类中的Tie方法只是一个构造函数来初始化Count属性。 我在做什么错了吗? 我已经使用VB.NET很长时间了,C#就在最近,所以我仍然很熟悉它。 仍然熟悉它。 谢谢, MiguelHello,I have the following classes:namespace MyApp.Models {public class Tie {public Count Count { get; set; }public Tie() {this.Count = new Count();}}}namespace MyApp.Models{public class Count{public int File { get; set; }public int Professor { get; set; }}}However, when I access the Tie class in my code the only think VisualStudio recognizes is:Tie.Tie.Tie ...Why can''t I access Tie.Count ?The Tie method inside the Tie class is only a constructor toinitialize the Count property.Am I doing something wrong?I have been using VB.NET for a long time and C# just recently so I amstill getting familiar with it.Thanks,Miguel推荐答案 6月25日上午11:14,shapper < mdmo ... @ gmail.comwrote:On Jun 25, 11:14 am, shapper <[email protected]: 您好, 我有以下课程: 命名空间MyApp.Models { 公共类领带{ 公共计数计数{get;组; } public Tie(){ this.Count = new Count(); } }} 名称空间MyApp.Models { 公共班计数 { public int File {get;组; } public int教授{get;组; } } } 然而,当我在我的代码中访问Tie类时,唯一的想法是Visual Studio认可的是: Tie.Tie.Tie ... 为什么我无法访问Tie.Count ? Tie类中的Tie方法只是一个构造函数,用于初始化Count属性。 我做错了什么? 我已经使用VB.NET很长时间了,C#就在最近,所以我还是b $ b仍然熟悉它。 谢谢, MiguelHello,I have the following classes:namespace MyApp.Models { public class Tie { public Count Count { get; set; } public Tie() { this.Count = new Count(); } }}namespace MyApp.Models{ public class Count { public int File { get; set; } public int Professor { get; set; } }}However, when I access the Tie class in my code the only think VisualStudio recognizes is:Tie.Tie.Tie ...Why can''t I access Tie.Count ?The Tie method inside the Tie class is only a constructor toinitialize the Count property.Am I doing something wrong?I have been using VB.NET for a long time and C# just recently so I amstill getting familiar with it.Thanks,Miguel 尝试实例化一个Tie类然后尝试访问; 领带=新领带(); tie.Counttry instantiating a Tie class then try to access;Tie tie = new Tie();tie.Count 6月25日,4 :14 * pm,shapper< mdmo ... @ gmail.comwrote:On Jun 25, 4:14*pm, shapper <[email protected]: 我有以下课程: 名称空间MyApp.Models { * public class Tie { * * public Count Count {get;组; } * * public Tie(){ * * * this.Count = new Count(); * *} *}} 名称空间MyApp.Models { *公共班计数 * { * * public int File {get;组; } * * public int教授{get;组; } *} } 然而,当我在我的代码中访问Tie类时,唯一的想法视觉 Studio认可的是: Tie.Tie.Tie ... 为什么我不能访问Tie。好吗?I have the following classes:namespace MyApp.Models {* public class Tie {* * public Count Count { get; set; }* * public Tie() {* * * this.Count = new Count();* * }* }}namespace MyApp.Models{* public class Count* {* * public int File { get; set; }* * public int Professor { get; set; }* }}However, when I access the Tie class in my code the only think VisualStudio recognizes is:Tie.Tie.Tie ...Why can''t I access Tie.Count ? Count是一个实例属性 - 所以你应该可以这样做: Tie someTie = new Tie(); 计数= someTie.Count; 但你不能这样做: 计数= Tie.Count; JonCount is an instance property - so you should be able to do:Tie someTie = new Tie();Count count = someTie.Count;But you can''t do:Count count = Tie.Count;Jon 因为这对你来说比较新,我''我会尝试发布我认为你会追求的内容。 我虽然不确定。 我将一件事改名为TheCount。所以我们可以在 讨论中避免含糊不清。 领带t1 =新领带(); 控制台.WriteLine(t1.TheCount.File); Console.WriteLine(t1.TheCount.Professor); public班级领带 { 私人计数_count1 = null; 公共计数TheCount { get { 返回_count1; } 套装 { _count1 = value; } } public Tie() { this.TheCount = new Count(); } } 公共班计数 { 私人int _file = 0; private int _prof = 0; public int文件 { get { return _file; } 设定 { _file =值; } } public int教授 { get { return _prof; } 套装 { _prof =值; } } } " shapper" < md ***** @ gmail.com写信息 新闻:e6 ************************* ********* @ m36g2000 hse.googlegroups.com ...Since this is newer to you, I''m gonna try to post what I think you''re after.I"m not sure though.I renamed one thing to "TheCount" so we can avoid ambiguity in thediscussion.Tie t1 = new Tie();Console.WriteLine(t1.TheCount.File);Console.WriteLine(t1.TheCount.Professor);public class Tie{private Count _count1 = null;public Count TheCount{get{return _count1;}set{_count1 = value;}}public Tie(){this.TheCount = new Count();}}public class Count{private int _file = 0;private int _prof = 0;public int File{get{return _file;}set{_file = value;}}public int Professor{get{return _prof;}set{_prof = value;}}}"shapper" <md*****@gmail.comwrote in messagenews:e6**********************************@m36g2000 hse.googlegroups.com... 你好, 我有以下几个类: 名称空间MyApp.Models { 公共类领带{ 公共计数计数{get;组; } public Tie(){ this.Count = new Count(); } } } 名称空间MyApp.Models { 公共班计数 { public int File {get;组; } public int教授{get;组; } } } 但是,当我在我的代码中访问Tie类时,只能想到Visual 工作室认可的是: Tie.Tie.Tie ... 为什么我不能访问Tie.Count? Tie类中的Tie方法只是一个构造函数来初始化Count属性。 我在做什么错了吗? 我已经使用VB.NET很长时间了,C#就在最近,所以我仍然很熟悉它。 仍然熟悉它。 谢谢, MiguelHello,I have the following classes:namespace MyApp.Models { public class Tie { public Count Count { get; set; } public Tie() { this.Count = new Count(); } }}namespace MyApp.Models{ public class Count { public int File { get; set; } public int Professor { get; set; } }}However, when I access the Tie class in my code the only think VisualStudio recognizes is:Tie.Tie.Tie ...Why can''t I access Tie.Count ?The Tie method inside the Tie class is only a constructor toinitialize the Count property.Am I doing something wrong?I have been using VB.NET for a long time and C# just recently so I amstill getting familiar with it.Thanks,Miguel 这篇关于班级......为什么这不起作用?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持! 上岸,阿里云! 08-27 09:05