|
-
March 24th, 2011, 05:51 AM
#1
learning C# help
Using .Net Framework 4.0
I am brand new 2 programming and learning how to write programs in C# while practicing some exercise I'm getting this error:
Properties.Dog.Color.get' must declare a body because it is not marked abstract or extern. Automatically implemented properties must define both get and set accessors. H:\Documents and Settings\noname\Desktop\C# Oreilly\ConsoleApplication1\ConsoleApplication2\Program.cs 17 13 ConsoleApplication2
I cannot seem to figure it out
Code:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace properties
{
public class Dog
{
private int weight;
private string color;
public string Color
{
get
{
return color;
}
set
{
color = value;
}
}
public Dog(int myWeight, string myColor)
{
weight = myWeight;
color = myColor;
}
}
public class Tester
{
static void Main( )
{
}
}
}
-
March 24th, 2011, 07:31 PM
#2
Re: learning C# help
I dunno ... works for me as a console application
Code:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace ConsoleApplication1
{
class Program
{
static void Main(string[] args)
{
System.Console.WriteLine(args.Length);
string color;
Dog fido = new Dog(12, "red");
fido.Color = "blue";
color = fido.Color;
}
}
public class Dog
{
private int weight;
private string color;
public string Color
{
get
{
return color;
}
set
{
color = value;
}
}
public Dog(int myWeight, string myColor)
{
weight = myWeight;
color = myColor;
}
}
}
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|