xFactorSchool.com(Beta)
How to Do Examples
Python Examples
HTML Examples
Code Examples
C Code Examples
C++ Code Examples
C# Code Examples
Java Code Examples
Python Code Examples
HTML Code Examples
CSS Code Examples
JavaScript Code Examples
Online Editor
C Code Editor
C++ Code Editor
C# Code Editor
Java Code Editor
Python Code Editor
HTML Code Editor
CSS Code Editor
JavaScript Code Editor
Practice how to create a method in a class in C#
C# Online Editor
Execute Code
More C# Sample Code
using System; namespace ExampleApp { class Program { static void Main(string[] args) { Math mathObj = new Math(); //object of math class //calling the method and assigning the return value to sumVariable int sumVariable = mathObj.AddNumber(10, 20); Console.WriteLine( "The sum of 10 and 20 is {0}.", sumVariable ); } } //This is a class class Math { //This is the method of the class public int AddNumber(int x, int y) { return x + y; } } }