Search
 
SCRIPT & CODE EXAMPLE
 

CSHARP

c# callback action lambda

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

public class CallbackUsingActionAndLambdaDemo : MonoBehaviour {

	void Start(){
		DoWork ((String result) => Debug.Log (result)); //passing the executable code to DoWork() as a callback (after doing work in DoWork(), the code which has been sent will be executed)
	}

	public void DoWork(Action<string> callback){
		bool isWorkDone;

		//do work here
		isWorkDone = true;

		if (isWorkDone)
			callback ("yes work is done successfully");
		else
			callback ("sorry work is not done");

	}
}
Comment

PREVIOUS NEXT
Code Example
Csharp :: c# object is in object list 
Csharp :: concat arrays .net 
Csharp :: c# obsolete class 
Csharp :: how to get mouse position c# 
Csharp :: how to create url parameters for URi C# 
Csharp :: winforms input box 
Csharp :: finding keys in the registry 
Csharp :: C# get column of 2d array 
Csharp :: timer unity 
Csharp :: center mouse unity 
Csharp :: hide numericUpDown arrows 
Csharp :: c# ? 
Csharp :: c# linq select specific columns 
Csharp :: Get unique id of Device 
Csharp :: serenity frameword order column 
Csharp :: unity scene switch 
Csharp :: c#l list<string initialize 
Csharp :: dinktopdf page break 
Csharp :: c# group array based on first character 
Csharp :: how to make randomizer c# 
Csharp :: C# order a sorted list by key 
Csharp :: number to character c# 
Csharp :: c# split quotation 
Csharp :: c# enum get string value 
Csharp :: Unity upload image to project 
Csharp :: c# builder pattern fluent example 
Csharp :: Get a list of distinct values in List 
Csharp :: c# timer single tick 
Csharp :: display image script unity 
Csharp :: summernote dropdown plugin 
ADD CONTENT
Topic
Content
Source link
Name
1+3 =