marceloviana
marceloviana
Reputation Top 1%
Marcelo Viana
12 Snippets  (67th place)
Published
1 Channel
Created
4 Channels
Following
18 hours ago
Last Visit
Sep 29, 2016
Registered
285 points  (83rd place)
Reputation
Top 10% Publisher
Junior Code Generator
Serious Code Generator
Junior Publisher
Serious Publisher
Junior Trend Maker
Junior Autobiographer
Senior Autobiographer

Recent Snippets See all snippets by marceloviana

public by marceloviana created 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 created 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 created 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 created 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 marceloviana created Nov 14, 2016  113  2  3  0

Csharp consumindo Rest + lendo JSON

using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Net;
using System.IO;
using Newtonsoft.Json;
using Newtonsoft.Json.Linq;

namespace ExemploChatBot
{
    public partial class Chat : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {

        }

        protected void enviar_Click(object sender, EventArgs e)
        {
            string txt_campo_texto = campo_texto.Text;

            var url = "http://128.0.0.1:5000/site?id=2542&texto_digitado="+ txt_campo_texto + "";

            var syncClient = new WebClient();
            var content = syncClient.DownloadString(url);            

            dynamic registro = JObject.Parse(content);
            campo_texto.Text = registro.pergunta;

        }
    }
}
;