This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| using System; | |
| using System.Collections.Generic; | |
| using System.Data.Entity; | |
| using System.Diagnostics; | |
| using System.IO; | |
| using System.Linq; | |
| using System.Threading; | |
| using System.Threading.Tasks; | |
| namespace ConsoleApplication1 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| private static bool IsValidCNPJ(string cnpj) | |
| { | |
| var mul1 = new[] {5, 4, 3, 2, 9, 8, 7, 6, 5, 4, 3, 2}; | |
| var mul2 = new[] {6, 5, 4, 3, 2, 9, 8, 7, 6, 5, 4, 3, 2}; | |
| var cpnjWithoutCheckDigit = cnpj.Substring(0, 12); | |
| var sum = 0; | |
| for (var i = 0; i < 12; i++) | |
| sum += int.Parse(cpnjWithoutCheckDigit[i].ToString())*mul1[i]; | |
| var rest = sum % 11; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| public static string Mod11(string pis) | |
| { | |
| var sum = 0; | |
| var fat = 2; | |
| for (var i = pis.Length-1; i >= 0; i--) | |
| { | |
| sum += Convert.ToInt32(pis[i].ToString()) * fat; | |
| fat++; | |
| if (fat > 9) | |
| fat = 2; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| using System; | |
| using System.Reflection.Emit; | |
| namespace GerandoCodigoEmExecucao | |
| { | |
| class Program | |
| { | |
| static void Main(string[] args) | |
| { | |
| Func<int, int, int> soma = Soma; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| using System.Data.SqlClient; | |
| using Microsoft.SqlServer.Management.Common; | |
| using Microsoft.SqlServer.Management.Smo; | |
| namespace ConsoleApplication9 | |
| { | |
| class Program | |
| { | |
| static void Main(string[] args) | |
| { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| using System; | |
| namespace ConsoleApplication2 | |
| { | |
| public class ExceptionCSharp5 : Exception | |
| { | |
| public ExceptionCSharp5() | |
| : base("Mensagem") | |
| { } | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| var type = typeof(Teste); | |
| var assemblyName = new AssemblyName("TesteNamespace"); | |
| var assemblyBuilder = AppDomain.CurrentDomain.DefineDynamicAssembly(assemblyName, AssemblyBuilderAccess.Run); | |
| var moduleBuilder = assemblyBuilder.DefineDynamicModule(assemblyName.Name); | |
| var typeBuilder = moduleBuilder.DefineType("TesteNamespace." + type.Name + "Proxy", TypeAttributes.Public, type); | |
| var jsonIgnoreType = typeof(JsonIgnoreAttribute); | |
| var constructorInfo = jsonIgnoreType.GetConstructor(Type.EmptyTypes); | |
| var attributeBuilder = new CustomAttributeBuilder(constructorInfo, Type.EmptyTypes); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| ^(?([\d.-]{11})(\d{3}\.){2}\d{3}-\d{2}|\d{2}(\.\d{3}){2}/\d{4}-\d{2})$ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| public enum Operações | |
| { | |
| Soma = 1, | |
| Subtração, | |
| Multiplicação, | |
| Divisão | |
| } | |
| var type = typeof(Operações); | |
| var todasOperações = Enum.GetNames(type).Select(n => new { Name = n, Value = (int)Enum.Parse(type,n) }); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| using System.Data.Entity; | |
| using System.Data.Entity.ModelConfiguration.Conventions; | |
| namespace ConsoleApplication2 | |
| { | |
| class Program | |
| { | |
| static void Main(string[] args) | |
| { | |
| using (var ctx = new Ctx()) |