xFactorSchool.com
Python
JavaScript
How to Do Examples
C 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 Compilers
C Compiler
C++ Compiler
C# Compiler
Java Compiler
Python Compiler
HTML Code Editor
CSS Code Editor
JavaScript Compiler
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; } } }