Thread: "auto-implemented property" feature.

  1. #1
    Registered User
    Join Date
    Mar 2009
    Posts
    48

    "auto-implemented property" feature.

    Hey,

    Good Day!

    I can't build this project.
    IDE: VS2005

    is it for .net framework 2.0 can't support the new feature, or other reason?
    thanks!

    Code:
    using System;
    
    public class Tmp3Customer
    {
        public int ID { get; set; }
        public string Name { get; set; }
    }
    
    public class AutoImplementedCustomerManager
    {
        static void Main()
        {
            Tmp3Customer cust = new Tmp3Customer();
    
            cust.ID = 1;
            cust.Name = "Amelio Rosales";
    
            Console.WriteLine(
                "ID: {0}, Name: {1}",
                cust.ID,
                cust.Name);
    
            Console.ReadKey();
        }
    }
    Show:
    ....
    D:\study\code\Lesson10\ConApp10\ConApp10\AutoImple mented.cs(5,21): error CS0501: 'Tmp3Customer.ID.get' must declare a body because it is not marked abstract or extern
    D:\study\code\Lesson10\ConApp10\ConApp10\AutoImple mented.cs(5,26): error CS0501: 'Tmp3Customer.ID.set' must declare a body because it is not marked abstract or extern
    D:\study\code\Lesson10\ConApp10\ConApp10\AutoImple mented.cs(6,26): error CS0501: 'Tmp3Customer.Name.get' must declare a body because it is not marked abstract or extern
    D:\study\code\Lesson10\ConApp10\ConApp10\AutoImple mented.cs(6,31): error CS0501: 'Tmp3Customer.Name.set' must declare a body because it is not marked abstract or extern
    --------------------------------------------------------
    Newbie
    C/C#/C++
    swimming/cycling/running
    There is nothing more powerful than an idea.
    Except for an idea put into action.
    --------------------------------------------------------

  2. #2
    Confused Magos's Avatar
    Join Date
    Sep 2001
    Location
    Sweden
    Posts
    3,145
    Seems like you're right, I can't see any other reason.
    MagosX.com

    Give a man a fish and you feed him for a day.
    Teach a man to fish and you feed him for a lifetime.

  3. #3
    Ethernal Noob
    Join Date
    Nov 2001
    Posts
    1,901
    Auto-Implemented Properties (C# Programming Guide)


    In C# 3.0 and later, auto-implemented properties make property-declaration more concise when no additional logic is required in the property accessors. They also enable client code to create objects When you declare a property as shown in the following example, the compiler creates a private, anonymous backing field can only be accessed through the property's get and set accessors.

  4. #4
    Registered User
    Join Date
    Mar 2009
    Posts
    48
    Get it.

    C# 2.0 / 3.0 - Lanugage Standard
    .net 2.0 / .net 3.0|3.5 - Microsoft framework version
    VS2005 / VS 2008 - IDE Version

    Could i install .net 3.0|3.5 based on VS 2005?
    How about the compatibility?


    I won't plan to install VS2008...
    A root cause is that all my current development based on VS2005 and
    my laptop is not high performance too.


    Thanks!
    --------------------------------------------------------
    Newbie
    C/C#/C++
    swimming/cycling/running
    There is nothing more powerful than an idea.
    Except for an idea put into action.
    --------------------------------------------------------

  5. #5
    Registered User
    Join Date
    Mar 2009
    Posts
    48
    I find this article, it is clearly to my misunderstanding.
    :-)

    Using .NET 3.5 and Visual Studio 2005

    thank you!
    --------------------------------------------------------
    Newbie
    C/C#/C++
    swimming/cycling/running
    There is nothing more powerful than an idea.
    Except for an idea put into action.
    --------------------------------------------------------

  6. #6
    Registered User
    Join Date
    Jun 2009
    Posts
    1
    Cheers and we look forward to your Forum Favourites selections!


    pret auto

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Edit and continue feature
    By George2 in forum C# Programming
    Replies: 2
    Last Post: 04-27-2008, 06:15 AM
  2. What is a Map/Table? How is it Implemented?
    By Artist_of_dream in forum C++ Programming
    Replies: 4
    Last Post: 02-13-2005, 03:42 PM
  3. Best IDE feature
    By nickname_changed in forum A Brief History of Cprogramming.com
    Replies: 26
    Last Post: 01-18-2004, 10:43 PM
  4. how are copy protections implemented?
    By mickey in forum C++ Programming
    Replies: 6
    Last Post: 03-17-2003, 10:29 PM
  5. Beta-testing: new hexeditor feature
    By Sang-drax in forum C++ Programming
    Replies: 0
    Last Post: 01-05-2003, 06:30 PM