Search
 
SCRIPT & CODE EXAMPLE
 

CSHARP

c# method

using System;
public class Program
{
  public static void Main(String[] args)
  {
    int a = 1;
    int b = 2;
    int answer = sum(a,b);//calling the method
    Console.WriteLine(answer);
  }
  //sum is a method
  static int sum(int a,int b) 
  {
    return a+b;
  }
}
Comment

methods c#

Search on YT: Brackeys C# Methods (for a good explaination)
Comment

method c#

static void myMethod()
{
	Console.WriteLine("Hi")
}
Comment

c# method

/* --Syntax--
[] = Optional
<> = Required
[modifiers] <return type> <identifier>([<parameter type> <parameter identifier>])
{
  //Code block
  //Return is required if type is not 'void'
  return null;
} */
//Example
/*Modifiers   Return Type	Identifier	Parameters, optional, separate with comma*/
public static bool 			MyFunc		(int x, int y)
{
  	x = x * 2;
    return x > y; //Omittable if return type is void
}
//Shortened to return the given expression |Expression body definition|	
public static int answerToEverything() 		=> 42;
Comment

C# Methods

namespace ConsoleApp21
{
    internal class Program
    {
        static void Main(string[] args)
        {
            SayHi();
            Console.ReadLine();
        }   
        static void SayHi()
        {
            Console.WriteLine("Hello User");
        }
    }
}   //Must be within internal class curley bracket
Comment

PREVIOUS NEXT
Code Example
Csharp :: how to remove all whitespace from a string in c# 
Csharp :: c# generate guid from hash 
Csharp :: c# get function name 
Csharp :: how get data from json in c# 
Csharp :: checking a gamobjects layer 
Csharp :: c# combobox add item 
Csharp :: c# .net 3.5 post json httpclient 
Csharp :: how to define a function in c# 
Csharp :: unity reference textmeshpro 
Csharp :: c# array display 
Csharp :: how to create a variable in c# 
Csharp :: unity banner Ad position 
Csharp :: how to add to a list only items that are not already in the list c# 
Csharp :: c# allowedusernamecharacters 
Csharp :: c# sort int array 
Csharp :: c# add 2 arrays 
Csharp :: linq from multiple tables 
Csharp :: c# func 
Csharp :: how to create function in c# 
Csharp :: Get Last Access Time Of Directory C# 
Csharp :: c# override gethashcode 
Csharp :: get appsettings from app.config c# .net core 
Csharp :: ihttpactionresult to object c# 
Csharp :: how to keep rigidbody2D upright unity 
Csharp :: change line color in c# 
Csharp :: unity detect when an object has been clicked 
Csharp :: registry keys and values 
Csharp :: c sharp list 
Csharp :: Get all images from folder asp.net 
Csharp :: c# get random between 0 and 1 
ADD CONTENT
Topic
Content
Source link
Name
6+1 =