This file contains 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 ExemploNInject | |
{ | |
public class ExecutaDI | |
{ | |
private IServico _servico; | |
public ExecutaDI(IServico servico) | |
{ | |
_servico = servico; |
This file contains 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 ExemploNInject | |
{ | |
public interface IServico | |
{ | |
public void Executa(); | |
} | |
public class MeuServico : IServico |
This file contains 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.Data; | |
using Microsoft.Data.SqlClient; | |
namespace BasicDI | |
{ | |
class Program | |
{ | |
static void Main(string[] args) | |
{ |
This file contains 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 BasicDI | |
{ | |
public class ExecutaServico | |
{ | |
private IServico _servico; | |
public ExecutaServico(IServico servico) | |
{ | |
_servico = servico; |
This file contains 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; | |
public interface IServico | |
{ | |
public void Executa(); | |
} | |
public class ServicoCarro : IServico | |
{ | |
public void Executa() |
This file contains 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 class AcessoBanco | |
{ | |
IDbConnection _conexao; | |
public AcessoBanco(IDbConnection conexao) | |
{ | |
_conexao = conexao; | |
} | |
} |
This file contains 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 class AcessoBanco | |
{ | |
SqlConnection _conexao; | |
public AcessoBanco(SqlConnection conexao) | |
{ | |
_conexao = conexao; | |
} | |
} |
This file contains 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 class Customers | |
{ | |
public string CustomerID { get; set; } | |
public string CompanyName { get; set; } | |
public string City { get; set; } | |
} |
This file contains 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
string str = "Exemplo em C# 8"; | |
string palavra = str[^4..^0]; | |
Console.WriteLine(palavra); | |
string final = str[^4..]; | |
Console.WriteLine(final); | |
string inicio = str[..7]; | |
Console.WriteLine(inicio); |
This file contains 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
static void Main(string[] args) | |
{ | |
string str = "Exemplo em C# 8"; | |
foreach(var s in str[^4..str.Length]) | |
{ | |
Console.Write(s); | |
} | |
Console.WriteLine(""); | |
} |