Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR CSHARP

action c#

using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using System;

public class ActionDemo : MonoBehaviour {

	void Start(){
		Action<string> SampleAction; //action dont need an explicit delegate to be declared (Action is special kind of delegate which takes parameters but returns nothing)

		SampleAction = PrintMsg;
		SampleAction += delegate(string s) {Debug.Log("from anonymous method : "+s);} ; //using anonymous method
		SampleAction += s => Debug.Log("using lambda expression : "+s); //using lambda expression
		SampleAction ("Hello shrinath");
	}

	void PrintMsg(string msg1){
		Debug.Log ("msg : " + msg1);
	}
}
 
PREVIOUS NEXT
Tagged: #action
ADD COMMENT
Topic
Name
1+8 =