pppp pppp

pppp pppp

  • NA
  • 3
  • 0

I need share variables between various classes

Jan 6 2009 10:08 AM
I had this three classes:

Start.cs:
---------
using System;
using System.Windows.Forms;

namespace Test
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
        }

        static void Main(string[] args)
        {
            Uruchom();
        }

        public static void Uruchom()
        {
            Book written = new Book();
            Book bought = new Book();
            written.Author = "Test";
        }
    }
}

Variables.cs:
-------------
using System;
using System.Collections.Generic;
using System.Text;

namespace Test
{
    public class Book
    {
        public string Title;
        public string Author;
        public short YearPublished;
        public int NumberOfPages;
        public char CoverType;
    }
}

Checking.cs:
------------
using System;
using System.Collections.Generic;
using System.Text;

namespace Test
{
    private class Outside
    {
        private void SomethingElse()
        {
            Book written = new Book();

            Console.WriteLine("Author: {0}",written.Author);
        }
    }

I want to see and edit variables from class Book in other classes. I want to do as simplest as possible. I am competely newbie in Visual Studio 2005 C# programming.

Answers (2)