0

I have a simple class that creates unique ID numbers:

public static class ID
    {
        private static int iD = 0;

        public static int GetNextID()
        {
            return iD++;
        }
    }

If I want each instance of an abstract class to automatically get a new non changeable ID when instantiated, how do I go about that?

The following won't work:

public abstract class MyClass
    {
        protected const int ID = ID.GetNextID();
    }

Edited by DaveTran: n/a

3
Contributors
3
Replies
4
Views
6 Years
Discussion Span
Last Post by Mitja Bonca
This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.