Advertisement
Fhernd

UnsafeCadenaUnicode.cs

Jul 16th, 2015
1,156
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.68 KB | None | 0 0
  1. // OrtizOL - xCSw - http://ortizol.blogspot.com
  2.  
  3. using System;
  4.  
  5. unsafe struct UnsafeCadenaUnicode
  6. {
  7.     public short Longitud;
  8.     public fixed byte Bufer[30];    // Bloue de 30 bytes fijos.
  9. }
  10.  
  11. unsafe public class Entidad
  12. {
  13.     UnsafeCadenaUnicode cadena;
  14.    
  15.     public Entidad(string s)
  16.     {
  17.         cadena.Longitud = (short)s.Length;
  18.        
  19.         fixed (byte* puntero = cadena.Bufer)
  20.         {
  21.             for (int i = 0; i < s.Length; ++i)
  22.             {
  23.                 puntero[i] = (byte) s[i];
  24.             }
  25.         }
  26.     }
  27. }
  28.  
  29. public class PruebaEntidad
  30. {
  31.     public static void Main()
  32.     {
  33.         new Entidad("John Ortiz Ordoñez");
  34.     }
  35. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement