Created
February 1, 2019 03:37
-
-
Save Adobe-Android/fe05e0ba2bda63034b18d03d4be2443d to your computer and use it in GitHub Desktop.
Demo for creating a new object/type and creating an instance method on that class
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
namespace Class_Instance_Method | |
{ | |
class Employee | |
{ | |
public string Id { get; set; } | |
public string FullName { get; set; } | |
public string Email { get; set; } | |
public string Phone { get; set; } | |
public string doWork() | |
{ | |
return "Work has been completed by"; | |
} | |
} | |
} |
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 Class_Instance_Method | |
{ | |
class Program | |
{ | |
static void Main(string[] args) | |
{ | |
Employee employee = new Employee(); | |
employee.FullName = "Brown, David"; | |
var doWorkStr = employee.doWork(); | |
Console.WriteLine($"{doWorkStr} {employee.FullName}"); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment