Search
 
SCRIPT & CODE EXAMPLE
 

CSHARP

c# function return

// To create a function with a return value, note the variable
// type in front of the function name and add a return of the
// same type at the end.
static string lastFirst(string firstName, string lastName)
{
	string separator = ", ";
	string result = lastName + separator + firstName;
	return result;
}
Comment

how to return a value in c#

   void Start()
    {
        Debug.Log(Message()/*calling the function with its name*/);
    }

    string Message()/*you can make values to functions with () and {}*/
    {
        string message = "Hello world";
        return message;//this says which value will be returned
    }
Comment

c# how to return a function

public void DoSomething()                          // Action
public void DoSomething(int number)                // Action<int>
public void DoSomething(int number, string text)   // Action<int, string>

public int DoSomething()                           // Func<int>
public int DoSomething(float number)               // Func<float, int>
public int DoSomething(float number, string text)  // Func<float, string, int>
Comment

c# get the return value of a func

Func<int> function;
int returnValue;

function = () => 0;
returnValue = function();
Comment

C# return values

public async Task DeleteSchoolTask(int schoolNumber, int taskDetailId)
        {  
            var result = await GetTaskTypeAndId(taskDetailId);
            int taskId = result.Item1;
            string taskType = result.Item2;

            // step 1: delete attachment physically from server
            var fileService = new FileService(Logger, CurrentUser);
            var relativeFilePath = $"{schoolNumber}{Consts.RM_SCHOOL}{taskDetailId}";
            fileService.DeleteAttachmentFolderFromServer(Consts.CONFIG_SMP_UPLOADFILE_ROOTPATH, relativeFilePath);

            // step 2: delete records from database
            await _routineMaintenanceRepo.Value.DeleteSchoolTask(taskDetailId);
        }

        public async Task<(int, string)> GetTaskTypeAndId(int taskDetailId)
        {
            var detailRecord = await _routineMaintenanceRepo.Value.GetDetailRecord(taskDetailId);

            int taskId = 0;
            string taskType = "";

            switch (detailRecord.TaskType)
            {
                case 1:
                    taskId = (int)detailRecord.RoutineMaintenanceTaskId;
                    taskType = Consts.RM_DEFAULT;
                    break;
                case 2:
                    taskId = (int)detailRecord.RoutineMaintenanceTaskDuplicateId;
                    taskType = Consts.RM_DUPLICATE;
                    break;
                case 3:
                    taskId = (int)detailRecord.RoutineMaintenanceTaskSchoolId;
                    taskType = Consts.RM_SCHOOL;
                    break;
                default:
                    break;
            }
            return (taskId, taskType);
        }
Comment

PREVIOUS NEXT
Code Example
Csharp :: make all variables nonserizlized unity 
Csharp :: generate jwt token authorize(roles = admin ) not working .net core 403 
Csharp :: ignore collision unity 2d 
Csharp :: visibility bound to radio button wpf 
Csharp :: c# easy 
Csharp :: two lowest positive numbers given an array of minimum 
Csharp :: c# if loop 
Csharp :: DataTable GetErrors 
Csharp :: c# variable 
Csharp :: c# increment by 2 
Csharp :: c# silent execute exe 
Csharp :: Query mongodb collection as dynamic 
Csharp :: how to change the volume of all sound effects in monogame 
Csharp :: record keyword c# 
Csharp :: Last N lines from file 
Csharp :: isselected uicollectionview reused 
Csharp :: create new directory netrw 
Csharp :: ienumerable tolist 
Csharp :: unity move in x seconds to pos 
Csharp :: c# webrtc dll 
Csharp :: how to save in mongo different name field than model? c# 
Csharp :: sterge element din coada c# 
Csharp :: unity check if transform doent have parent 
Csharp :: c# Color Convert 
Csharp :: download and run exe c# 1 button 
Csharp :: you have the following c# code. stringbuilder sb = new stringbuilder(really long string); the really long string variable is a string in which a very long string is stored. 
Csharp :: gridview column cell alignment form c# 
Csharp :: unity torque distance joint 
Csharp :: ExpandoObject Syntax that Compile 
Csharp :: export xml 
ADD CONTENT
Topic
Content
Source link
Name
7+2 =