using System;
class Pen
{
public string Color;
private int Price;
public void SetPrice(int newPrice)
{
Price=newPrice;
}
public int GetPrice()
{
return Price;
}
public void SetColor(string newColor)
{
Color=newColor;
}
public string GetColor()
{
return Color;
}
}
class Test
{
public static void Main()
{
Pen myPen;
myPen.SetPrice(5);
myPen.Color="Black";
Console.WriteLine("The Price is {0}".myPen.GetPrice());
Console.WriteLine("The Color is {0}".myPen.Color);
}
}
出错:"string"并不包含对“mypen"的定义!
class Pen
{
public string Color;
private int Price;
public void SetPrice(int newPrice)
{
Price=newPrice;
}
public int GetPrice()
{
return Price;
}
public void SetColor(string newColor)
{
Color=newColor;
}
public string GetColor()
{
return Color;
}
}
class Test
{
public static void Main()
{
Pen myPen;
myPen.SetPrice(5);
myPen.Color="Black";
Console.WriteLine("The Price is {0}".myPen.GetPrice());
Console.WriteLine("The Color is {0}".myPen.Color);
}
}
出错:"string"并不包含对“mypen"的定义!
解决方案 »
- 又谁能够提供给我c#能使用到的行业(包括大分类、小分类等等)?
- 知了急急律令——牛鬼蛇神请进:ClickOnce按需更新的问题
- 求!!!string "1234" 转成 int 1234 函数(快快快)
- winform picturebox的重绘问题(介绍比较详细,有做过的,请贴代码,谢谢!)
- 救命!救命!
- 怎么获取另一个应用程序中的按钮点击事件?高手都来看看啊。。。
- .net中好象没有控件数组
- 可否指定哈希表的键值类型,以使访问时不必拆箱?
- 求解,C#一组json序列,分别获取每组的values
- 请问谁有WROX的《C#入门经典》的第26、27、28章源代码?
- session问题:当session为空时不能打开这个页面怎么判断?
- 随书源码:谁有sams的Managed directx kick start Graphics.And.Game.Programming源代码
Console.WriteLine("The Color is {0}".myPen.Color);.myPen
应该是
,myPen
Console.WriteLine("The Price is {0}".myPen.GetPrice());
Console.WriteLine("The Color is {0}".myPen.Color);.myPen
应该是
,myPen
Top
回复人: wolfofsky(风之武) ( ) 信誉:100 2005-03-23 16:25:00 得分: 0
Pen myPen=new Pen();