Dismiss Notice
Join Physics Forums Today!
The friendliest, high quality science and math community on the planet! Everyone who loves science is here!

Random # Generator

  1. Dec 17, 2013 #1

    TheDemx27

    User Avatar
    Gold Member

    Code (Text):
    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Text;

    namespace ConsoleApplication1
    {
        class Program
        {
            public class RandomNextDemo
            {
                static void NoBoundsRandoms(int seed)
                {
                    Console.WriteLine(
                        "\nRandom object, seed = {0}, no bounds:", seed);
                    Random randObj = new Random (seed);
                }
            }
           
            static void Main(string[] args)
            {
                RandomNextDemo.NoBoundsRandoms();

            }  
        }
    }
    Error1'ConsoleApplication1.Program.RandomNextDemo.NoBoundsRandoms(int)' is inaccessible due to its protection

    In C#, of course.
     
  2. jcsd
  3. Dec 17, 2013 #2
    Change the access modifier: static public void NoBoundsRandoms(int seed) by default it would set the access modifier to private which is what your current code does.
     
    Last edited: Dec 17, 2013
  4. Dec 17, 2013 #3

    TheDemx27

    User Avatar
    Gold Member

    Thanks, I guess I also forgot to give the method the value "seed" it called for.
     
Know someone interested in this topic? Share this thread via Reddit, Google+, Twitter, or Facebook




Similar Discussions: Random # Generator
Loading...