Question What is wrong?

Stilgar

New member
Joined
Feb 15, 2023
Messages
1
Programming Experience
Beginner
My script doesn't work and I don't why. Here are outputs:

1676452352953.png

And here is my scripts:
C#:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Security.Authentication.ExtendedProtection;
using System.Text;
using System.Threading.Tasks;

namespace ConsoleApp6
{
    internal class Program
    {
        static void Main(string[] args)
        {
            Kostka throw = new Kostka();
            throw.Hod();
            Console.ReadKey();
        }
    }
}
C#:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Security.Cryptography;
using System.Text;
using System.Threading.Tasks;

namespace ConsoleApp6
{
    internal class Kostka
    {
        public void Hod()
        {
            Random rnd = new Random();
            int Hodnota = rnd.Next(8,20);
            Console.WriteLine(Hodnota);
        }
    }
}
 
Last edited by a moderator:
throw is a reserved keyword, don't use it as variable name (or escape with @ if you really must).
 
Also, in C# code is called "code", not "scripts", unless you are writing C# code for the Unity game engine/framework. In that case C# code are called "scripts" (because they consider the core engine/framework code written in C++ and C# the "code").
 

Latest posts

Back
Top Bottom