Jump to content

Type of namespace name could not be found C# help please

SickSix66
using System;using System.Collections.Generic;using System.Linq;using System.Text;using System.Threading.Tasks;class ITSystem    {        private List<User> UserList;        private User LoginUser;        public ITSystem()        {            UserList = new List<User>();            UserList.Add(new User("Default Admin", "Administrator", "Password", true));      LoginUser = null;        }        public bool Login(string loginID, string password)        {            foreach (user z in UserList)            {                if (loginID.Equals(z.loginID))                {                    if (z.CheckPassword(Password) == true)                    {                        LoginUser = z;      return true;                    }                    else                    {                        return false;                    }                }            }        }        public void AddUser(User user)        {            if ((LoginUser != null) && (LoginUser.IsAdmin == true))            {                UserList.Add(user); }        }        public List<user> GetAllUsers()        {            return UserList;        }        public void Logout()        {            LoginUser = null;        }    }using System;using System.Collections.Generic;using System.Linq;using System.Text;using System.Threading.Tasks;  class Program  {    static void Main(string[] args)    {      ITSystem slickback = new ITSystem();      string username = Console.ReadLine();      string password = Console.ReadLine();      slickback.Login(username, password);      slickback.AddUser(new User("Administrator", "Admin", "Password", true));      slickback.AddUser(new User("boy","gay","Password", true));      slickback.AddUser(new User("girl","woman","Password", true));      foreach(User z in slickback.GetAllUsers())      {        Console.WriteLine(z.ToString());      }      slickback.Logout();    }  }using System;using System.Collections.Generic;using System.Linq;using System.Text;using System.Threading.Tasks;namespace ConsoleApplication11{    class User    {        public string Name;        public string LoginID;        private string Password;        public bool IsAdmin;        public User(string name, string loginID, string password, bool isAdmin)        {            Name = name;            LoginID = loginID;            Password = password;            IsAdmin = isAdmin;        }        public bool CheckPassword(string password){if (Password.Equals(password)){return true;}else{return false;}}        public string ToString()        {            string charset = "";            charset += "ABCDEFGHIJKLMNOPQRSTUVWXYZ";            charset += "ABCDEFGHIJKLMNOPQRSTUVWXYZ";            charset += "abcdefghijklmnopqrstuvwxyz";            charset += "abcdefghijklmnopqrstuvwxyz";            charset += "abcdefghijklmnopqrstuvwxyz";            charset += "0123456789";            charset += "0123456789";            CipherMachine z = new CipherMachine(charset, 10);            string cipher = z.Encrypt(Password);            return string.Format("{0},{1},{2},{3}", Name, LoginID, cipher, IsAdmin);        }    }}using System;using System.Collections.Generic;using System.Linq;using System.Text;using System.Threading.Tasks;class CipherMachine{ private List<char> Charset; private int Key; public CipherMachine(string c, int k) {  Charset = new List<char>(c);  Key = k; } public string Encrypt(string plain) {  string cipher = "";  foreach(char i in plain)  {   cipher += Charset.ElementsAt(Charset.IndexOf(i) + Key);  }  return cipher; }}

 

Link to comment
Share on other sites

Link to post
Share on other sites

Nonono, that is not how you ask a question. If you expect someone to help you, provide the minimum reproducible steps and a proper error message, which tells exactly where it goes wrong. You can't just dump your code, even worse, you can't just dump your code unindented and uncommented and expect someone to figure out what you were thinking and where the error is.

Link to comment
Share on other sites

Link to post
Share on other sites

Nonono, that is not how you ask a question. If you expect someone to help you, provide the minimum reproducible steps and a proper error message, which tells exactly where it goes wrong. You can't just dump your code, even worse, you can't just dump your code unindented and uncommented and expect someone to figure out what you were thinking and where the error is.

 

It makes me not want to give a shit at all  :lol:

The single biggest problem in communication is the illusion that it has taken place.

Link to comment
Share on other sites

Link to post
Share on other sites

I think I see your problem, but without telling me where or how you are getting this error, or even cutting the classes up into individual sections, or even attempting to fix the spacing, or adding any comments to tell us what is happening, I'm going to pass. Hell you didn't even give a sentence to explain what your code is TRYING to do. 

Link to comment
Share on other sites

Link to post
Share on other sites

SickSix66 please give more information, but I haven't done C# for a bit, but don't all classes have to have a namespace associated with them?

 

namespace [name] {

//classes in here valid

}

//classes not in here invalid?

 

Maybe I am wrong, I haven't actually tried and as an fyi as others have said please put more effort into explaining the problem you have, it makes it hard to guess and given the length of code you posted any details are usually helpful (and make people more willing to help and go the extra mile)

0b10111010 10101101 11110000 00001101

Link to comment
Share on other sites

Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×