c# function
public void SayHello()
{
Console.WriteLine("Hello") ;
}
//as basic as it gets
//for a function
c# function
public void SayHello()
{
Console.WriteLine("Hello") ;
}
//as basic as it gets
//for a function
function c#
public int AddNumbers(int number1, int number2)
{
int result = number1 + number2;
return result;
}
function in c#
//function example
using System;
public class Program
{
static void function(){
Console.WriteLine("I am a function!");
}
public static void Main()
{
function();
}
}
functions in c#
using UnityEngine;
public class Gun : MonoBehaviour
{
public float damage = 10f;
public float range = 100f;
public Camera fpsCam;
public ParticleSystem muzzleFlash;
// Update is called once per frame
void Update()
{
if (Input.GetButtonDown("Fire1"))
{
// Call function
Shoot();
}
}
// Declare & Program function
void Shoot ()
{
muzzleFlash.Play();
RaycastHit hit;
if (Physics.Raycast(fpsCam.transform.position, fpsCam.transform.forward, out hit, range))
{
Debug.Log(hit.transform.name);
Target target = hit.transform.GetComponent<Target>();
if (target != null)
{
target.TakeDamage(damage);
}
}
}
}
functions c#
public void SayHello(string name)
{
Console.WriteLine("Hello");
}
public void SayName()
{
Console.WriteLine("What is your name?");
string name = Console.ReadLine();
SayHello(name);
}
Copyright © 2021 Codeinu
Forgot your account's password or having trouble logging into your Account? Don't worry, we'll help you to get back your account. Enter your email address and we'll send you a recovery link to reset your password. If you are experiencing problems resetting your password contact us