C# String Theory—Memory Sharing
Microsoft .NET Framework, ASP.NET, Visual C# (CSharp, C Sharp, C-Sharp) Developer Training, Visual Studio
| CSharp-Online.NET:Articles |
| C# Articles |
| edit |
[edit]
Memory Sharing
To understand how to optimize C# strings, one needs to understand the answer to the following question.
Given two string variables, how can one get both string variables to point to the same memory location?
The object of the exercise is not to define two seperate strings that contain the same value. Rather, the object is to define two string variables both of which reference the same, single memory location containing a unique string value.
The answer to the question is simple and intuitive; but, an understanding of the not so obvious reasons behind the answer enables programmers to write faster and more efficient code.
|

