Skip to content

Instantly share code, notes, and snippets.

@HiroNakamura
Last active September 13, 2021 00:17
Show Gist options
  • Save HiroNakamura/0f3d69d060eaa87a005a9f03ff6f6555 to your computer and use it in GitHub Desktop.
Save HiroNakamura/0f3d69d060eaa87a005a9f03ff6f6555 to your computer and use it in GitHub Desktop.
Dotnet para principiantes

.Net

Programando en CSharp

Mostrar versión de Dotnet

$ dotnet --version

Crear proyecto

$ dotnet new console -o auditor
$ ls
$ tree

Program.cs

using System;

namespace auditor{
    class Program{
       static void Main(string[] args){
             var mensage = "Hola, mundo en C#!!";
             Console.WriteLine("{0}",mensaje);
       }
    }
}

Ejecutar

$ dotnet run
namespace auditor
{
public class MyBase
{
//protected members.
protected int _intValue { get; set; }
protected string _stringValue { get; set; }
//Base Constructor
public MyBase(int intParam, string strParam)
{
_intValue = intParam;
_stringValue = strParam;
}
//Overridable method
public virtual int WhatsMyValue()
{
return _intValue;
}
}
/// <summary>
/// Derived Class.
/// </summary>
public class MyDerivedClass : MyBase
{
// <summary>
// Must create a constructor since MyBase does not have a
// parameter-less constructor.
// But we just call : base()
public MyDerivedClass(int intParam, string strParam) : base(intParam, strParam)
{
//Do not need to set the parameters, just need to define the constructor.
}
// <summary>
// Override parent class method.
// </summary>
// <returns></returns>
public override int WhatsMyValue()
{
return base.WhatsMyValue() * 69;
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment