Αποτελέσματα Αναζήτησης
25 Ιαν 2010 · No, there is no replacement for an #include statement. C# is an object-oriented language where code is organised into classes. You can use code from one class in another class depending on its visibility, and you can split the code from a single class across multiple source files using partial classes.
25 Αυγ 2014 · The compiler doesn't know that the actual object contained in getitem is of type MyClass, because you've told it to expect an object, which could be just about anything. Imagine you'd done this instead: List<object> items = new List<object>(); items.Add( "Hello, World!" ); object getitem = items[0]; int itemid = getitem.id; // <-error
23 Φεβ 2022 · In C#, a method can return any type of data including objects. In other words, methods are allowed to return objects without any compile time error. Example 1: // C# program to illustrate the concept // of the method returning an object using System; class Example { // Private data member private string str; // Method to set the value of str public
22 Απρ 2023 · Open Program.cs. It should look like this: C# Copy. // See https://aka.ms/new-console-template for more information . Console.WriteLine("Hello, World!"); In this tutorial, you're going to create new types that represent a bank account. Typically developers define each class in a different text file.
1 Φεβ 2023 · #if, along with the #else, #elif, #endif, #define, and #undef directives, lets you include or exclude code based on the existence of one or more symbols. Conditional compilation can be useful when compiling code for a debug build or when compiling for a specific configuration.
Everything in C# is associated with classes and objects, along with its attributes and methods. For example: in real life, a car is an object. The car has attributes, such as weight and color, and methods, such as drive and brake. A Class is like an object constructor, or a "blueprint" for creating objects.
3 Νοε 2023 · In this article. Exceptions are used to indicate that an error has occurred while running the program. Exception objects that describe an error are created and then thrown with the throw statement or expression. The runtime then searches for the most compatible exception handler.