0
malloc and strings in C#
As I first started in C, the most basics tasks I used to do in C using the console are just so confusing and I still don’t get them in C#. How to make an empty string and later on the program add chars to each of its positions? As the string and its size are not defined when declaring the variable, I don’t know how to do it. In C I would use malloc (memory allocation). The MSDN website, besides being amazing to have access to its content, it’s still too “advanced” for autodidacts beginners.
1 ответ
+ 1
C is a really low level programming language
C# is a much higher level programming language
In C# a lot of work is done for you by the .net frame work.
Higher is not better but means you do not have to worry about low level task like allocating memory.
string input; //to define a string no size needed
input = "hello"; //to assign hello to the string
input = input + "world"; //to add characters to the string
input = ""; //to clear the string