?
?
Explore posts from servers
CC#
Created by ? on 1/4/2023 in #help
How do I pass 1 argument in lambda expression?
11 replies
CC#
Created by ? on 12/10/2022 in #help
Double check if an object is one of provided types
64 replies
CC#
Created by ? on 11/26/2022 in #help
❔ Windows Forms different controls but same event doing different code?
private void OnSecondsChange(object sender, EventArgs e)
{
textBoxUpTime.Text += $"{sender} fired out"; // somehow distinguish the sender and behave differently later in the code
}
private void OnSecondsChange(object sender, EventArgs e)
{
textBoxUpTime.Text += $"{sender} fired out"; // somehow distinguish the sender and behave differently later in the code
}
I was wondering if there is a way I can link one method to multiple controls events (such as OnClick) and depending on which element fired the event do something different? For example there are 4 buttons and each has the same OnClick event method linked but I want the code for each button behave slightly different
50 replies
CC#
Created by ? on 11/6/2022 in #help
The type name 'ServiceController' could not be found in the namespace 'System.ServiceProcess'.
8 replies
CC#
Created by ? on 11/6/2022 in #help
Write to file not working (StreamWriter)
using System;
using System.Numerics;
using System.Text;
using System.IO;
namespace Username
{
class Program
{
static void Main()
{
bool end = false;
string filePath = @"C:\Users\Administrator\Desktop\HEXes.txt";

StreamWriter hap = new(filePath, false, Encoding.Unicode);

hap.WriteLine($"{F:N0} is {F:X}"); // there are variables I didn't mention, I just wanted to show here I write to file

hap.Close();
Console.ForegroundColor = ConsoleColor.Yellow;
Console.Write("\nPress any key to continue...");
Console.ReadKey();
}
}
}
using System;
using System.Numerics;
using System.Text;
using System.IO;
namespace Username
{
class Program
{
static void Main()
{
bool end = false;
string filePath = @"C:\Users\Administrator\Desktop\HEXes.txt";

StreamWriter hap = new(filePath, false, Encoding.Unicode);

hap.WriteLine($"{F:N0} is {F:X}"); // there are variables I didn't mention, I just wanted to show here I write to file

hap.Close();
Console.ForegroundColor = ConsoleColor.Yellow;
Console.Write("\nPress any key to continue...");
Console.ReadKey();
}
}
}
It creates HEXes.txt but the file is empty Never mind, my silly mistake. Closing.
1 replies
CC#
Created by ? on 11/4/2022 in #help
delegate inside our outside class?
delegate void ADelegate(); // here?
public class PlayerShip : MonoBehaviour
{
delegate void ADelegate(); // or here?
event ADelegate DelegateHandler;
}
delegate void ADelegate(); // here?
public class PlayerShip : MonoBehaviour
{
delegate void ADelegate(); // or here?
event ADelegate DelegateHandler;
}
Should I create a delegate inside or outside a class? Is there a difference?
19 replies
CC#
Created by ? on 11/2/2022 in #help
Hexadecimal format specifier not working
for(int X = 1 ; X <= 5 ; X++)
{
var F = Math.Pow(63, X);
Console.WriteLine($"{F:X}");
}
for(int X = 1 ; X <= 5 ; X++)
{
var F = Math.Pow(63, X);
Console.WriteLine($"{F:X}");
}
For some reason this is not working and I receive an error: FormatException: Format specifier was invalid.
6 replies
CC#
Created by ? on 10/26/2022 in #help
Why Predicate contains in and parentheses?
9 replies