Search
 
SCRIPT & CODE EXAMPLE
 

CSHARP

C# actions

//Action is a invokeable container for Mehod or function method 
//that doesnt return anything. They can accept inputs based on the generals 
//that you template on. If you need a return check out the Func Class
//example:
Action YourActionProperty = new Action(()=>{/*do something*/});
//or
Action YourActionProperty = ()=>{/*do something*/};
//or
Action<int/*Or some other types followed by others comma seperated*/> 
YourParamitarizedActionProperty =
  (x/*Each Param will be to the comma seperated types*/)=>
  {/*do some with the inputs*/});

// you can invloke them by calling their invokes.
YourActionProperty.Invoke();
YourParamitarizedActionProperty.Invoke(5);
//The last is the basic sycronous way. For a aysnc call uses
YourActionProperty.BeginInvoke();
YourParamitarizedActionProperty.BeginInvoke(5);
//although awaiting is not required should you need to await a aysnc call use
YourActionProperty.EndInvoke();

//You can also fill them with defined methods in a class if you wish, 
//but the signatures must match.
Action YourActionDefinedProperty = YourDefinedMethod;
void YourDefinedMethod()
{
  //do something
}
Comment

action delegate c#

  private void ShowContentThreadSafe(int level)
  {
            
      if (UcView.TreeList.InvokeRequired)
       {
          	UcView.TreeList?.Invoke(new Action1<int>(a => ShowContent(level)));
       }
       else
        	ShowContent(level);
            
   }
Comment

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);
	}
}
Comment

C# Action Delegate

//one of three built-in generic delegate types:

static void ConsolePrint(int i)
{
    Console.WriteLine(i);
}

static void Main(string[] args)
{
    Action<int> printActionDel = ConsolePrint;
    printActionDel(10);
}
Comment

PREVIOUS NEXT
Code Example
Csharp :: what is int.parse in c# 
Csharp :: c# sort array by value 
Csharp :: round image unity 
Csharp :: how to add object in dictionary in c# 
Csharp :: Storing Data within your TileEntity 
Csharp :: error cs1585 unity 
Csharp :: blazor use static json files 
Csharp :: RestRequest AdvancedResponseWriter site:stackoverflow.com 
Csharp :: unity SceneTemplatePipeline 
Csharp :: if session is not active then redirect to login page mvc.net 
Csharp :: c# bool? to bool 
Csharp :: discord bot c# how to refresh message 
Csharp :: read only variable in c# 
Csharp :: c# namespace name form1 could not be found 
Csharp :: deleting an item from a vector c# 
Csharp :: project camera view to texture 
Csharp :: #movement speed c 
Csharp :: photon 
Csharp :: Handlebars c# datetime now 
Csharp :: unity ar scale 
Csharp :: c# name script 
Csharp :: C# return dictionary string/integer from comparison of List and Array 
Csharp :: GridViewColumn url wpf 
Csharp :: allelrt box wpf 
Csharp :: delete content from file c# 
Csharp :: c# array of class objects initialization with constructor 
Csharp :: create blazor web assembly 
Csharp :: händelsereportage 
Csharp :: difference between %e/E, %f/F and %g/G in program C 
Csharp :: c# creat pen 
ADD CONTENT
Topic
Content
Source link
Name
3+1 =