title: having issues when extracting char values, using unsafe char* in a struct []
body: <p>in this code i am trying to simulate a task that populats an array of structs,
  ...unsafe to get as much throughoutput as can be achived.</p>
  
  <p>the issue is that i when calling the fucntion and itterating on the result
  shows different characters but within the scope of <code>GetSomeTs()</code> it's fine.</p>
  
  <p>so just before the return i test one of the elements and it prints the correct value.</p>
  
  <p>this is the testing struct.</p>
  
  <pre><code>public unsafe struct T1
  {
      public char* block = stackalloc char[5];&lt;--will not compile so the process will be done within a local variable inside a method
  }
  
  public unsafe struct T1
  {
      public char* block;
  }
  
      static unsafe T1[] GetSomeTs(int ArrSz)
      {
          char[] SomeValChars = { 'a', 'b', 'c', 'd', 'e' };
          T1[] RtT1Arr = new T1[ArrSz];
  
          for (int i = 0; i &lt; RtT1Arr.Length; i++)
          {
              char* tmpCap = stackalloc char[5];
  
              for (int l = 0; l &lt; 5; l++)
              {
                  SomeValChars[4] = i.ToString()[0];
                  tmpCap[l] = SomeValChars[l]; 
              }
  
  
              RtT1Arr[i].block = tmpCap;//try 1
              //arr[i].block = &amp;tmpCap[0];//try 2
          }
             // here its fine
          Console.WriteLine("{0}", new string(RtT1Arr[1].block)); 
          return RtT1Arr;
      }
  </code></pre>
  
  <p>but using it anywhere else printing garbage.</p>
  
  <pre><code>void Main()
  {
       T1[] tstT1 = GetSomeTs(10);
  
          for (int i = 0; i &lt; 10; i++)
          {
              Console.WriteLine("{0}", new string(tstT1[i].block));//,0,5, Encoding.Default));
          }
  }
  </code></pre>