KnowledgeHub
Questions
Tags
Users
Search
Alex Rivera
|
Logout
Edit Question
Title
Body
In C# when I want to call a static method of a class from another static method of that class, is there a generic prefix that I can use such as PHP's self:: instead of the class name? So in the below example, instead of saying Customer.DatabaseConnectionExists() , how can I say something like Self.DatabaseConnectionExists() so e.g. later if I change the name of the class I don't have to go change all the prefixes? class Customer { public string FirstName { get; set; } public string LastName { get; set; } public static Customer GetCurrentCustomer() { if (Customer.DatabaseConnectionExists()) { return new Customer { FirstName = "Jim", LastName = "Smith" }; } else { throw new Exception("Database connection does not exist."); } } public static bool DatabaseConnectionExists() { return true; } }
Tags (comma-separated)
Save Edits
Cancel