38 lines
1.0 KiB
C#
38 lines
1.0 KiB
C#
namespace CommonIssues
|
|
{
|
|
internal class Program
|
|
{
|
|
static void Main(string[] args)
|
|
{
|
|
int num1 = 10;
|
|
int num2 = 0; // This will cause a divide by zero issue
|
|
|
|
// The following line should handle the potential exception properly
|
|
Console.WriteLine("Division Result: " + Divide(num1, num2));
|
|
|
|
// Unused variable
|
|
int unusedVariable = 5;
|
|
|
|
// A poorly named variable
|
|
int a = 7;
|
|
|
|
// An if statement that should use braces
|
|
if (num1 > num2)
|
|
Console.WriteLine("Num1 is greater");
|
|
|
|
// A method without a return type
|
|
PrintMessage("Hello, World!, World! 12345678");
|
|
}
|
|
|
|
static int Divide(int x, int y)
|
|
{
|
|
return x / y; // Potential divide by zero exception if y is 0
|
|
}
|
|
|
|
static void PrintMessage(string message) // Should return something (or be void)
|
|
{
|
|
Console.WriteLine(message);
|
|
}
|
|
}
|
|
}
|