[Tutorial] Simple Command Prompt Responder

Transcribe
by Transcribe · 22 posts
12 years ago in .Net (C#, VB, etc)
Posted 10 years ago
How would a beginner get started with learning how to write C++?
Posted 10 years ago
this will be very useful as I try to learn this a bit, so thank you for the list of places to read up
Posted 8 years ago
This takes me back learning C++ turbo making hangman, slot machines, and even some number games like sodoku! Though, I wish to make porn games but getting into programming isn't such a bad idea!
Posted 8 years ago
Elie wrote:
How would a beginner get started with learning how to write C++?there are many resources, I learnt it from books but I can suggest some:http://www.learncpp.com/
http://xoax.net/
The C/C++ Essential Training course from Lynda.com is pretty nice
http://www.cplusplus.com/doc/tutorial/


Very useful....very informative....thanks for sharing this with us....love to see more of it... :bunny:
Posted 6 years ago
Made it a bit more simpler
Code
using System;
using System.Threading.Tasks;

namespace IMVUMAfia
{
    class Program
    {
        static void Main(string[] args) => new Program().StartAsync().GetAwaiter().GetResult();

        int Age { get; set; }
        string Username { get; set; }       

        async Task StartAsync()
        {
            Console.WriteLine("Enter your name: ");
            Username = Console.ReadLine();
            if (string.IsNullOrWhiteSpace(Username)) throw new Exception("Username cannot be empty!");
            Console.WriteLine("Enter your age: ");
            if (!int.TryParse(Console.ReadLine(), out int AgeInput)) throw new Exception("Please enter valid age.");
            Age = AgeInput;
            Console.WriteLine($"Hello {Username}! Your age is {Age}");
            await Task.Delay(-1);
        }
    }
}


You can also have local variables instead of having properties. It's not necessary to create a user object unless you are working with a large collection of data.
Posted 6 years ago
@Zix


Zix wrote:
Made it a bit more simpler


It's nice to seem someone using Expression Bodied Methods, a new feature of c# 6.

Zix wrote:
You can also have local variables instead of having properties. It's not necessary to create a user object unless you are working with a large collection of data.


True, local variables would be a better choice than auto properties in this instance.
Posted 6 years ago
Yeah. Gotta keep up with the new changes and most of them are fun to use. :tlasmug:

Whenever it's class objects, DI comes to my mind immediately.
Something like this: https://github.com/Yucked/Valerie/blob/ ... art.cs#L20
Main Way: https://github.com/Yucked/Valerie/blob/ ... ler.cs#L14
One way to pull objects from DI: https://github.com/Yucked/Valerie/blob/ ... ext.cs#L29

Really keeps your code neat and understandable.
Posted 6 years ago
Yeah, unfortunately I have to code with security in mind so I can't always use the new features cause they make the code too neat that's really clear what's going on.

Create an account or sign in to comment

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

Sign in

Already have an account? Sign in here

SIGN IN NOW

Create an account

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

REGISTER A NEW ACCOUNT