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 :: set background from C# wpf 
Csharp :: get list of constants in class c# 
Csharp :: c# comments 
Csharp :: by value by reference c# 
Csharp :: c# HttpResponseMessage postResponse = client.PostAsync 
Csharp :: static initializer 
Csharp :: how to stop a coroutine unity c# 
Csharp :: Default property value in C# 
Csharp :: matrix transpose c# 
Csharp :: camelCase and snakeCase 
Csharp :: c# dapper execute stored procedure with parameters 
Csharp :: unity unit testing 
Csharp :: action c# 
Csharp :: send email every 5 minutes c# 
Csharp :: jtoken toobject is not exact double 
Csharp :: DataGridView set column cell Combobox 
Csharp :: c# null check 
Csharp :: c# create default instance of type 
Csharp :: degree between two points latitude longitude c# 
Csharp :: optional parameter get request c# 
Csharp :: c# accept any enum 
Csharp :: c# execute after delay 
Csharp :: c# .net RemoveClaim auth 
Csharp :: office open xml check if row is empty 
Csharp :: F# tuple get item 
Csharp :: c# add field to expando object 
Csharp :: detect location from ip address .net core 
Csharp :: vb.net get double item in list osf string 
Csharp :: C# how to search textfile and append 
Csharp :: Delegate no parameter no return 
ADD CONTENT
Topic
Content
Source link
Name
6+8 =