working on it ...

Filters

Explore Public Snippets

Sort by

Found 17k snippets

    public by marceloviana modified 18 hours ago  11  0  2  0

    Chamando função assincrona via console

    static void Main()
    {
        RunAsync().Wait();
    }
    
    private static async Task RunAsync()
    {
        …
    }

    public by marceloviana modified Mar 29, 2017  76  0  3  0

    Converte string em UFT-8

    byte[] bytes = Encoding.Default.GetBytes(myString);
    myString = Encoding.UTF8.GetString(bytes);
    

    public by marceloviana modified Dec 19, 2016  245  0  3  0

    Formatar double para ,00

    //Converte double 
    
    double valor = double.Parse("100".ToString());
    
    string.Format("{0:n2}", decimal.Parse(valor.ToString())

    public by marceloviana modified Dec 5, 2016  181  3  3  1

    Csharp ler Json e percorrer

    var url = "http://xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx";
    var sysnClient = new WebClient();
    string content = sysnClient.DownloadString(url);
    
                
    List<divida> lista_dados = new JavaScriptSerializer().Deserialize<List<cliente>>(content);
    
    string nomecompleto = "";
    
    foreach (divida registro in lista_dados) {
      nome_completo = registro.nome_completo;
    }
    
    txt_nomecompleto.Text = nomecompleto;

    public by Geometry modified Sep 25, 2016  170  0  3  0

    Sum: Matrix sum.

    Matrix sum. A matrix whose sum will be calculated. The dimension in which the sum will be calculated. A location where the result of this operation will be stored, avoiding unnecessary memory allocations.
    /// <summary>
            ///   Matrix sum.
            /// </summary>
            ///
            /// <param name="matrix">A matrix whose sum will be calculated.</param>
            /// <param name="dimension">The dimension in which the sum will be
            ///   calculated.</param>
            /// <param name="result">A location where the result of this operation will be stored,
            ///   avoiding unnecessary memory allocations.</param>
            ///
    #if NET45
            [MethodImpl(MethodImplOptions.AggressiveInlining)]
    #endif
            public static decimal[] Sum(this decimal[,] matrix, int dimension, decimal[] result)
            {
                if (matrix == null) 
                    throw new ArgumentNullException("matrix");
    
                int rows = matrix.GetLength(0);
                int cols = matrix.GetLength(1);
    
                if (dimension == 0)
                {
                    for (int j = 0; j < cols; j++)
                    {
                        decimal s = 0;
                        for (int i = 0; i < rows; i++)
                            s = (decimal)(s + (decimal)matrix[i, j]);
                        result[j] = s;
                    }
                }
                else if (dimension == 1)
                {
                    for (int j = 0; j < rows; j++)
                    {
                        decimal s = 0;
                        for (int i = 0; i < cols; i++)
                            s = (decimal)(s + (decimal)matrix[j, i]);
                        result[j] = s;
                    }
                }
                else
                {
                    throw new ArgumentException("Invalid dimension", "dimension");
                }
    
                return result;
            }

    public by Geometry modified Sep 25, 2016  182  1  3  0

    Random: Creates a matrix with uniformly distributed random data.

    Creates a matrix with uniformly distributed random data.
    /// <summary>
    ///   Creates a matrix with uniformly distributed random data.
    /// </summary>
    /// 
    public static decimal[,] Random(int size, decimal min, decimal max, bool symmetric = false, decimal[,] result = null)
    {
        if (result == null)
            result = new decimal[size, size];
    
        var random = Accord.Math.Random.Generator.Random;
    
        if (symmetric)
        {
            for (int i = 0; i < size; i++)
                for (int j = i; j < size; j++)
                    result[i, j] = result[j, i] = (decimal)random.NextDouble() * (max - min) + min;
        }
        else
        {
            for (int i = 0; i < size; i++)
                for (int j = i; j < size; j++)
                    result[i, j] = (decimal)random.NextDouble() * (max - min) + min;
        }
        return result;
    }

    public by Geometry modified Aug 6, 2016  258703  1  5  0

    SetUnmanagedMemory: Fill memory region with specified value.

    Fill memory region with specified value. Destination pointer. Filler byte's value. Memory block's length to fill. Return's value of - pointer to destination.
    /// <summary>
    /// Fill memory region with specified value.
    /// </summary>
    /// 
    /// <param name="dst">Destination pointer.</param>
    /// <param name="filler">Filler byte's value.</param>
    /// <param name="count">Memory block's length to fill.</param>
    /// 
    /// <returns>Return's value of <paramref name="dst"/> - pointer to destination.</returns>
    /// 
    public static unsafe byte* SetUnmanagedMemory(byte* dst, int filler, int count)
    {
        return memset(dst, filler, count);
    }

    public by Geometry modified Aug 6, 2016  176227  0  5  0

    SetUnmanagedMemory: Fill memory region with specified value.

    Fill memory region with specified value. Destination pointer. Filler byte's value. Memory block's length to fill. Return's value of - pointer to destination.
    /// <summary>
    /// Fill memory region with specified value.
    /// </summary>
    /// 
    /// <param name="dst">Destination pointer.</param>
    /// <param name="filler">Filler byte's value.</param>
    /// <param name="count">Memory block's length to fill.</param>
    /// 
    /// <returns>Return's value of <paramref name="dst"/> - pointer to destination.</returns>
    /// 
    public static IntPtr SetUnmanagedMemory(IntPtr dst, int filler, int count)
    {
        unsafe
        {
            SetUnmanagedMemory((byte*)dst.ToPointer(), filler, count);
        }
        return dst;
    }

    public by Geometry modified Aug 6, 2016  192249  0  5  0

    CopyUnmanagedMemory: Copy block of unmanaged memory.

    Copy block of unmanaged memory. Destination pointer. Source pointer. Memory block's length to copy. Return's value of - pointer to destination. This function is required because of the fact that .NET does not provide any way to copy unmanaged blocks, but provides only methods to copy from unmanaged memory to managed memory and vi
    /// <summary>
    /// Copy block of unmanaged memory.
    /// </summary>
    /// 
    /// <param name="dst">Destination pointer.</param>
    /// <param name="src">Source pointer.</param>
    /// <param name="count">Memory block's length to copy.</param>
    /// 
    /// <returns>Return's value of <paramref name="dst"/> - pointer to destination.</returns>
    /// 
    /// <remarks><para>This function is required because of the fact that .NET does
    /// not provide any way to copy unmanaged blocks, but provides only methods to
    /// copy from unmanaged memory to managed memory and vise versa.</para></remarks>
    /// 
    public static unsafe byte* CopyUnmanagedMemory(byte* dst, byte* src, int count)
    {
        return memcpy(dst, src, count);
    }

    public by Geometry modified Aug 6, 2016  177360  0  5  0

    CopyUnmanagedMemory: Copy block of unmanaged memory.

    Copy block of unmanaged memory. Destination pointer. Source pointer. Memory block's length to copy. Return's value of - pointer to destination. This function is required because of the fact that .NET does not provide any way to copy unmanaged blocks, but provides only methods to copy from unmanaged memory to managed memory and vi
    /// <summary>
    /// Copy block of unmanaged memory.
    /// </summary>
    /// 
    /// <param name="dst">Destination pointer.</param>
    /// <param name="src">Source pointer.</param>
    /// <param name="count">Memory block's length to copy.</param>
    /// 
    /// <returns>Return's value of <paramref name="dst"/> - pointer to destination.</returns>
    /// 
    /// <remarks><para>This function is required because of the fact that .NET does
    /// not provide any way to copy unmanaged blocks, but provides only methods to
    /// copy from unmanaged memory to managed memory and vise versa.</para></remarks>
    ///
    public static IntPtr CopyUnmanagedMemory(IntPtr dst, IntPtr src, int count)
    {
        unsafe
        {
            CopyUnmanagedMemory((byte*)dst.ToPointer(), (byte*)src.ToPointer(), count);
        }
        return dst;
    }
    • Public Snippets
    • Channels Snippets