SplikZerys
SplikZerys
CC#
Created by SplikZerys on 6/22/2024 in #help
Delegates
c#
using System.Net.Mime;

namespace ConsoleApp18;
class Program
{
static void Main(string[] args)
{
// 3
// Now we declare in method

Print print;
print = Text;
print += CountSymbols;

// But here it works well
}

// 1
// During declaring the first variable we can add method
// But when trying to add one more it's now working at all
// With 'Cannot resolve symbol 'print' or 'CountSymbols''
public static Print print = Text;
print += CountSymbols;

// 2
// For example, we can only add value in case during declaring variable
public static Print print2;
print2 = Text;

public static void CountSymbols(string text)
{
Console.WriteLine($"Text Length: {text.Length}");
}
public static void Text(string text)
{
Console.WriteLine($"{text}");
}
}
// We can declare delegate in and outside class but not in method
delegate void Print(string text);

c#
using System.Net.Mime;

namespace ConsoleApp18;
class Program
{
static void Main(string[] args)
{
// 3
// Now we declare in method

Print print;
print = Text;
print += CountSymbols;

// But here it works well
}

// 1
// During declaring the first variable we can add method
// But when trying to add one more it's now working at all
// With 'Cannot resolve symbol 'print' or 'CountSymbols''
public static Print print = Text;
print += CountSymbols;

// 2
// For example, we can only add value in case during declaring variable
public static Print print2;
print2 = Text;

public static void CountSymbols(string text)
{
Console.WriteLine($"Text Length: {text.Length}");
}
public static void Text(string text)
{
Console.WriteLine($"{text}");
}
}
// We can declare delegate in and outside class but not in method
delegate void Print(string text);

11 replies