Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

virtual properties

Tags:

c#

People also ask

What are virtual properties?

Virtual land exists in the virtual world, aka, the metaverse. The land can be used for anything, from an empty plot to a mansion, or even an art gallery. Virtual land is usually bought on an NFT marketplace like Sandbox and Decentraland, and land ownership is recorded on the blockchain that the NFT exists.

What is the point of virtual land?

Virtual lands are digital spaces or land plots that you can buy, sell, build upon, and explore in a virtual world. Many platforms and blockchain games like Axie Infinity, Decentraland, and The SandBox sold their limited virtual lands to huge companies and other investors.

Is virtual land a good investment?

It is regarded as a wise investment with the potential for future rewards by those who purchase it. Some investors predict virtual land would follow in the footsteps of Bitcoin's success when it was originally established, making virtual land similar to Bitcoin.

What is the metaverse real estate?

Enter metaverse real estate, an online platform where people can connect to play games, release products, offer services, and host events. Businesses often own these virtual properties. And, just like any other type of real estate, they can be bought, sold, purchased, and leased.


public virtual ICollection<B> Prop { get; set; }

Translates almost directly to:

private ICollection<B> m_Prop;

public virtual ICollection<B> get_Prop()
{
    return m_Prop;
}

public virtual void set_Prop(ICollection<B> value)
{
    m_Prop = value;
}

Thus, the virtual keyword allows you to override the property in sub-classes just as you would the above get/set methods:

public override ICollection<B> Prop
{
    get { return null; }
    set { }
}

In object-oriented programming, a virtual property is a property whose behavior can be overridden within an inheriting class. This concept is an important part of the polymorphism portion of object-oriented programming (OOP).

look at the example below:

public class BaseClass
{

    public int Id { get; set; }
    public virtual string Name { get; set; }

}

public class DerivedClass : BaseClass
{
    public override string Name
    {
        get
        {
            return base.Name;
        }

        set
        {
            base.Name = "test";
        }
    }
}

at the presentation level:

        DerivedClass instance = new DerivedClass() { Id = 2, Name = "behnoud" };

        Console.WriteLine(instance.Name);

        Console.ReadKey();

the output will be "test" because the "Name" property has been overridden in the derived class(sub class).


In Entity Framework (which I believe your example refers to), your POCO classes are created and wrapped into a proxy class. Proxy class is a descendant of the class that you declare, so your class A becomes a base class. This proxy class is populated with data and returned back to you. This is necessary in order to track changes. Have a look at this article http://technet.microsoft.com/en-us/query/dd456848

I had a similar problem in trying to understand this and after a few debugging sessions and seeing the proxy classes and reading about tracking changes it made be figure out why it is declared the way it is.


Properties are actually specials cases of Getter and Setter methods. So they are like combinations of Getter and Setter methods as shown below:

private string _name;

public string GetName()
{
   return _name;
}

public void SetName(string value)
{
   this._name = value;
}

So virtual keyword is same for properties as well which means it is overrideable by the child classes and initial implementation can be changed.


Properties are a shortened form of accessor methods (Get & Set). That means that the virtual keyword has the same meaning as with any other method. That means you can override it in derived classes.


You can have methods (often), properties, indexers or events, the virtual keyword has the same meaning : modifying the meaning (override) of the base class item. With properties, you can change the get/set accessors.