Thanks to Mr. Vijendra,
http://www.codeproject.com/Tips/803656/Practical-Difference-between-Const-ReadOnly
http://www.codeproject.com/Tips/803656/Practical-Difference-between-Const-ReadOnly
/*a perfect number is a positive integer that is equal to the sum of
its proper positive divisors, that is, the sum of its positive divisors
excluding the number itself.
Read here: en.wikipedia.org/wiki/Perfect_number
*/
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace ConsoleApplication2
{
class Program
{
static void PerfectNumber(int a)
{
int sum = 0;
for (int idx = 1; idx < a; idx++)
{
int id = a % idx;
if (id == 0)
{
sum = sum + idx;
}
}
Console.WriteLine();
Console.WriteLine("The sum of all it's proper divisors is: "+sum+'\n');
if (sum == a)
{
Console.WriteLine("YES! "+a+ " is a Perfect number");
}
else
Console.WriteLine("No! " + a + " is NOT a Perfect number");
}
static void Main(string[] args)
{
Console.WriteLine("********************************************************");
Console.WriteLine("To Check the whether entered number is Perfect Number !");
Console.WriteLine();
Console.Write("Enter the a desired Number:");
int abc = int.Parse(Console.ReadLine());
PerfectNumber(abc);
}
}
}
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Diagnostics;
namespace ConsoleApplication4
{
class Program
{
static void Main(string[] args)
{
Console.WriteLine("Do You want to create a user ID in your system?");
string st = Console.ReadLine();
if (st == "yes")
{
Console.WriteLine("Enter the name of the user to be create:");
string user = Console.ReadLine();
Console.WriteLine("Enter the password:");
string password = Console.ReadLine();
string userdetails = "@/C" + " " + "net user" + " " + user + " " + password + " " + "/add";
Process.Start("cmd.exe", userdetails);
Console.WriteLine("User has been created succesfully");
Process.Start("cmd.exe", @"/C pause");
}
else
Console.WriteLine("Thank for you not interested in to create user accounts");
}
}
}
--- If you want to find out whether user account has been created
Press Windows + R
=> cmd
=> net user
Here you will find list of user accounts created
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.Net;
namespace WindowsFormsApplication1
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void button1_Click(object sender, EventArgs e)
{
string domainName = System.Net.NetworkInformation.IPGlobalProperties.GetIPGlobalProperties().DomainName;
string hostName = Dns.GetHostName();
string SysName = "";
if (!hostName.Contains(domainName))
SysName = hostName + "." + domainName;
else
SysName = hostName;
MessageBox.Show("Your System is not connected to Domain!");
MessageBox.Show("Your Computer Name is "+SysName);
}
}
}
When you click on the button it will displays as follows,
"Your system is not connected to domain"
and
"Your computer Name is WINSERVER03"
-- Check whether particular table exists in the databaseif exists (select * from sys.objects where object_id = object_id(N'[#table]'))begindrop table #tableenduse tempdbgo--Create the temp table #tablecreate table #table (IPValues varchar(200))insert into #table exec master..xp_cmdshell 'ipconfig'-- select the data from the table #tableselect * from #table where IPValues is not null-- You will get results like this