if condition multiple values

Let’s say i need to satisfy if condition based on multiple values.

For example, i would like to display some message limited to some users.

Let’s say i’ve {A,B,C,D,E,F} users

i would like to display Hello User for only {A,B,C} users

Normally we write if condition like

if(user == “A” || user ==”B” || user ==”C”)

{

<h2> Hello User </h2>

}

Instead we can write like this

if(new string[]{“A”,”B”,”C”}.Contains(user))
{
<h2> Hello User </h2>

}

Here, we have mentioned all values inside a string collection and comparing string collection with input user.
If user value exists in string collection then if condition will get satisfied.
That’s it Folks!!!

Advertisements

Angular Application with Node.js step-by-step installation

Angular5 Setup:

Step 1:
Create new folder in your desired location.for instance i’ve created a folder with name Node in E drive

Step 2:
download Node.js from https://nodejs.org/en/download/

step 3:
open command prompt and navigate to Node folder location

step 4:
write npm install @angular/cli and hit Enter some files will be downloaded.wait till the download get’s complete.usually it takes couple of minutes.

step 5:
After installation a folder with name ‘node_modules’ will be created in Node folder.

step 6:
come back to command prompt and type npm install -g @angular/cli then hit Enter. Again some set of files will be downloaded.wait till the download get’s completed.

step 7:
Type ng and hit Enter. Some files will be initialised.

step 8:
create new Angular project
Type ng new yourprojectname and hit Enter. Again some will be initialised.A new folder with name ‘yourprojectname’ will be created in Node folder.
After Successful project creation u will get these messages

Installed packages for tooling via npm.
Successfully initialized git.
Project ‘yourprojectname’ successfully created.

Now Node.js has been successfully installed.Next u need to download Visual Studio Code from https://code.visualstudio.com/download . A zip file will be downloaded extract it and install it after download.

Step 9:
Open Visual Studio code
Press Ctrl+Shift+E an explorer will be opened inside that there will be button with name Open Folder click on it and load ‘yourprojectname’ project from Node folder.Now all project related will be loaded in Explorer.

Step 10:
Click View –> Integrated Terminal
a powershell will be loaded in that type ng serve and hit Enter.The project will be compiled.
After compilation u will get a message like this
** NG Live Development Server is listening on localhost:4200, open your browser on http://localhost:6200/ **

copy http://localhost:6200/ and search in browser.

That’s it u a basic have created Angular Application using Node.js.

Enjoy!!!!