© 2026 Hedgehog Software, LLC

TwitterGitHubDiscord
More
CommunitiesDocsAboutTermsPrivacy
Search
Star
Setup for Free
C#C
C#•3y ago•
8 replies
Mishu Bellringer of Ostral-B

❔ ✅ Static vs. non-Static (?)

Hello hello (: Im a very beginner, and trying to learn about delegates. But i stumbled upon the topic of Static/NonStatic - i've read about what it does; Static members dont operate on the instance of a class, but the class itself, whereas non-static members operate on the instance.
(A memeber that keeps track of all the instances of a class could be static)

But i'm having much trouble deciding what should be static or not, even with the information. How do i decide it? I have this example, where i feel a static-method would be more flexible in the given context - but i dont know if i should?

internal class Book
    {
        // - Properties - //
        public string Title { get; set; }
        public string Author { get; set; }

        // - - Spezified Class Constructor - - //
        public Book(string title, string author)
        {
            Title = title;
            Author = author;
        }

        // - Defining the Delegate -  Dotnet: past-tense, -Handler 
        public delegate void BookNotificationSendedHandler(Book notification);

        // - - Methods - - //
        public void NotifySMS(Book book)
        {
            Console.WriteLine($"SMS Send: {book.Title} written by {book.Author} is available!");
        }
        public static void NotifyMail(Book book)
        {
            Console.WriteLine($"Mail Send: {book.Title} written by {book.Author} is available!");
        }
    }
internal class Book
    {
        // - Properties - //
        public string Title { get; set; }
        public string Author { get; set; }

        // - - Spezified Class Constructor - - //
        public Book(string title, string author)
        {
            Title = title;
            Author = author;
        }

        // - Defining the Delegate -  Dotnet: past-tense, -Handler 
        public delegate void BookNotificationSendedHandler(Book notification);

        // - - Methods - - //
        public void NotifySMS(Book book)
        {
            Console.WriteLine($"SMS Send: {book.Title} written by {book.Author} is available!");
        }
        public static void NotifyMail(Book book)
        {
            Console.WriteLine($"Mail Send: {book.Title} written by {book.Author} is available!");
        }
    }

Book codingBook = new("C# for Beginners", "TheGreatGhostOfC#");
Book cookingBook = new("Pipebombs and soup", "NYA");

Book.BookNotificationSendedHandler notifySMS = codingBook.NotifySMS;
Book.BookNotificationSendedHandler notifyMail = Book.NotifyMail;

notifySMS(codingBook);
notifyMail(cookingBook);
Book codingBook = new("C# for Beginners", "TheGreatGhostOfC#");
Book cookingBook = new("Pipebombs and soup", "NYA");

Book.BookNotificationSendedHandler notifySMS = codingBook.NotifySMS;
Book.BookNotificationSendedHandler notifyMail = Book.NotifyMail;

notifySMS(codingBook);
notifyMail(cookingBook);


Do i decide what is static or not or do some rules i may not understand/know yet decide what should be static or not?
Thanks very much in advance 🙂
C# banner
C#Join
We are a programming server aimed at coders discussing everything related to C# (CSharp) and .NET.
61,871Members
Resources
Was this page helpful?

Similar Threads

Recent Announcements

Similar Threads

Static vs Non-Static classes [Answered]
C#CC# / help
4y ago
Cannot access non-static method in static context?
C#CC# / help
4y ago
❔ Making properties accessible by both static and non-static methods
C#CC# / help
4y ago
Changing a value of non-static float from a static function
C#CC# / help
3y ago