如何纠正这个C#错误,因为我是初学者 [英] How to rectify this C# error because I am a beginner

查看:69
本文介绍了如何纠正这个C#错误,因为我是初学者的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

1.	using System;
2.	namespace Examples
3.	{
4.		 class Program
5.	{
6.		public static void Main(string[]args)
7.		{
8.			Laptop Lenovo=new Laptop("Lenovo");
9.			Lenovo.Price("$");
10.			Lenovo.Processor("i");
11.			Lenovo.Ram(2);
12.			Lenovo.HDD(500);
13.			
14.			Laptop Dell=new Laptop("Dell");
15.			Dell.Price("$");
16.			Dell.Processor("i");
17.			Dell.Ram(4);
18.			Dell.HDD(1);
19.			
20.			Laptop Sony=new Laptop("Sony");
21.		    Sony.Price("$");
22.			Sony.Processor("i");
23.			Sony.Ram(8);
24.			Sony.HDD(1);
25.			
26.			
27.		}
28.	}
29.	class Laptop:LaptopBase
30.	{
31.		public  LaptopBase(String LaptopName):base(LaptopName)
32.		{
33.			this.LaptopBase=LaptopName;
34.		
35.		  	} 
36.		class LaptopBase
37.		{
38.			public LaptopBase(String LaptopName)
39.			{
40.				Console.WriteLine(" "+LaptopName);
41.			}
42.		
43.		
44.		public void Price()
45.		{
46.		Console.WriteLine("$"+ 1000,"$"+2000,"$"+3000);
47.		}
48.	public void Processor()
49.	{
50.	Console.WriteLine("i"+3,"i"+5,"i"+7);
51.	}
52.		public void Ram()
53.		{
54.			Console.WriteLine(2+"GB",4+"GB",8+"GB");
55.		}
56.		public void HDD()
57.		{
58.			Console.WriteLine(500+"GB",1+"TB",1+"TB");
59.		}
60.	}
61.			}
62.	}



已添加代码块 - OriginalGriff [/ edit]



我有什么试过:



main.cs(31,10):错误CS1520:类,结构或接口方法必须有一个返回类型


[edit]Code block added - OriginalGriff[/edit]

What I have tried:

main.cs(31,10): error CS1520: Class, struct, or interface method must have a return type

推荐答案

);
10 .Linovo.Processor( i);
11 .Linovo.Ram ( 2 );
12 .Linovo.HDD( 500 );
13
14 。笔记本电脑Dell = new 笔记本电脑( Dell );
15 .Dell.Price(
"); 10. Lenovo.Processor("i"); 11. Lenovo.Ram(2); 12. Lenovo.HDD(500); 13. 14. Laptop Dell=new Laptop("Dell"); 15. Dell.Price("


);
16 。 Dell.Processor( i);
17 。 Dell.Ram( 4 );
18 。 Dell.HDD( 1 );
19
20 。笔记本电脑Sony = 笔记本电脑( Sony);
21 。 Sony.Price(
"); 16. Dell.Processor("i"); 17. Dell.Ram(4); 18. Dell.HDD(1); 19. 20. Laptop Sony=new Laptop("Sony"); 21. Sony.Price("


);
22 。 Sony.Processor( i);
23 。 Sony.Ram( 8 );
24 。 Sony.HDD( 1 );
25
26
27 。 }
28 。 }
29 class 笔记本电脑:LaptopBase
30 。 {
31 public LaptopBase( String LaptopName): base (LaptopName)
32 。 {
33 this .LaptopBase = LaptopName;
34
35 。 }
36 class LaptopBase
37 。 {
38 public LaptopBase( String LaptopName)
39 < /跨度>。 {
40 。 Console.WriteLine( + LaptopName);
41 。 }
42
43
44 public void 价格()
45 。 {
46 。 Console.WriteLine(
"); 22. Sony.Processor("i"); 23. Sony.Ram(8); 24. Sony.HDD(1); 25. 26. 27. } 28. } 29. class Laptop:LaptopBase 30. { 31. public LaptopBase(String LaptopName):base(LaptopName) 32. { 33. this.LaptopBase=LaptopName; 34. 35. } 36. class LaptopBase 37. { 38. public LaptopBase(String LaptopName) 39. { 40. Console.WriteLine(" "+LaptopName); 41. } 42. 43. 44. public void Price() 45. { 46. Console.WriteLine("


这篇关于如何纠正这个C#错误,因为我是初学者的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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