Skip to content

Instantly share code, notes, and snippets.

Avatar
🏠
Working Hard

Nan Wang nanwang2016

🏠
Working Hard
View GitHub Profile
View gist:22ee5e4603a113b6adb92fa6466b71dd
using System;
namespace TestFile
{
class Program
{
static void Main(string[] args)
{
int resultInt = PlusMethod(1, 2);
double resultDouble = PlusMethod(2.4, 4.4);
View Sealed Class in C#
using System;
namespace TestFile
{
class Program
{
static void Main(string[] args)
{
}
View Polymorphism in C# 01
using System;
namespace TestFile
{
class Program
{
static void Main(string[] args)
{
}
View Inheritance
using System;
namespace TestFile
{
class Program
{
static void Main(string[] args)
{
}
View using in C#
using System;
using System.IO;
namespace TestFile
{
class Program
{
//The text file's path is stored in 'filename'
static string filename = @"C:\Users\Nan\source\repos\Example.txt";
View Resource Release in C#
using System.IO;
namespace TestFile
{
class Program
{
//The text file's path is stored in 'filename'
static string filename = @"C:\Users\Nan\source\repos\Example.txt";
static void Main(string[] args)
View Write() and WriteLine() in C#
using System;
namespace TestFile
{
class Program
{
static void Main(string[] args)
{
Console.Write("This is Line 1");
Console.Write("This is Line 2");
View Private Constructor in C#
namespace TestFile
{
class Program
{
static void Main(string[] args)
{
//Only Defaul Constructor with parameters is valid, as Private Constructor is not allowed to create an instance.
Student UniStudent = new Student("Jack", "007");
}
}
View Static Class Constructor in C#
using System;
namespace TestFile
{
class Program
{
static void Main(string[] args)
{
//Both Static and Default constructors will invoke for first instance
Student UniStudent = new Student();
View gist:a82a8bb8ff8d81c85fc5b5c4e4cb51b5
using System;
namespace TestFile
{
class Program
{
static void Main(string[] args)
{
Student UniStudent = new Student("Jack", "007");
Student NewUniStudent = new Student(UniStudent);
You can’t perform that action at this time.