---
# System prepended metadata

title: 7.11 Code

---

# 7.11 Code

> Registration code, that cheks from an array if it has a match, if found, you need to apply an unique username.


```

namespace Registration
{
    internal class Program
    {
        static void Main(string[] args)
        {
            Console.WriteLine("Register");
            Console.WriteLine();

            string[,] userData = 
            {   // Note to my self the locked status value should be given by default -- May cause explotation of the aplication, in later development 
                { "Pekka", "password", "0", "Pekka Pekkanen", "160" }  //Test User for outputs
          
            };

            string Username, Password, Name, Surname, Height;
            //row formated to -1
            int row = -1;

            Console.Write("Username: ");
            Username = Console.ReadLine();

            //If username exist "Error" || Could be changed to an True/False method.
            if(GetRow(userData, Username) != -1)
            {
                Console.WriteLine("Username in use. \nChoose a new one.");
                // Call Registration method again
                
                
            }
            else
            {
                Console.Write("Password: ");
                Password = Console.ReadLine();

                Console.Write("Name: ");
                Name = Console.ReadLine();

                Console.Write("Surname: ");
                Surname = Console.ReadLine();

                Console.Write("Height: ");
                Height = Console.ReadLine();

                //Registration go on.
            }

            

        }


        //Loop throught userData for a username match
        // Ty Marlem xD for the code. Hokkus Pokkus Now Marlems code is copus!
        static int GetRow(string[,] Userdata, string username)
        {
            for (int i = 0; i < Userdata.GetLength(0); i++)
            {
                for (int j = 0; j < Userdata.GetLength(1); j++)
                {
                    if (Userdata[i, j].Equals(username))
                    {
                        return i;
                    }
                }
            }
            // Return -1 if it found a match.
            return -1;
        }

    }
}
```

# Opettelin Githubin käyttöä Azure ympäristössä.
* Pushattu oma osuus masteriin.