1. For example, there is a .cpp file, it has a method that does not belong to any space method(wchar_t ch) { .. } where this method may actually refer to, if you translate it into c #, creating a separate static class for such groups of methods ?
  2. There is a class, it is described, etc., but I noticed that there are "calls" of methods, without any description, that is, even the values ​​are not transferred to the static Class^ FromString(String ^ Source, keyType type, bool surround); but these methods are described below the class is not in any namespace namespace::class::method(String^ mng_str_ref, keyType type, bool surround) { .. } how does it work for example in c #? I can not compare such work, it seems a bit on the work of the interface, the analogue that in the class described such methods, somewhere outside the namespace it was implemented ... Something nonsense. Help me understand the work

    1 answer 1

    For example, there is a .cpp file, it has a method that does not belong to any space method (wchar_t ch) {..} where this method may actually refer to, if you translate it into c #, creating a separate static class for such groups of methods ?

    There are no global methods in C #, so yes, the method must be declared as a static member of a class. However, starting with C # 6.0, you can use using static to access a static method without specifying a type:

     public static class MyClass { public static int Foo(int x,int y) { return x + y; } } 

     using static ConsoleApplication1.MyClass; class Program { static void Main(string[] args) { Console.WriteLine(Foo(1, 2)); } } 

    There is a class, it is described, etc., but I noticed that there are "calls" of methods, without any description, that is, even the values ​​are not transferred ... but these methods are described below by a class not in any namespace ... how it works, for example in c #?

    In C ++, declaring declarations and implementations is used to put only method declarations in the header file. This is necessary in connection with the rules of the language regarding the redefinition of functions (header files are included in many places in the program, and the non-inline function can only be defined once). In C #, there is no need to separate the declaration and implementation, since there is no concept of header files and no forward declarations are used at all; language is different. Implementations of methods are written directly in the class declaration.

    If you still want to declare a method without implementation (for example, procurement for the future), there are partial-methods :

     public static partial class MyClass { static partial void Bar(); } 

     public static partial class MyClass { static partial void Bar() { Console.WriteLine("Hello"); } }