My Name Is Salman Masood , I am Computer Science &Amp; Maths Graduate from University of Karachi, Pakistan , Teaching Is My Passion and My Aim Is to Deliver All My Knowledge among Those Students Who Can'T Afford Tutors or Expensive Institute Fees. I Will Be Keep Sharing My All Knowledge and Information with You .... Remember Me in Your Prayers !
Friday, 25 May 2018
Check Palindrome using string function String copy , string Reverse, String
#include<stdio.h>
#include<conio.h>
#include <string.h>
main()
{
char s[50];
char d[50];
char t[50];
l1:
printf("Enter the string: ");
gets(s);
strcpy(t,s);
strcpy(d,strrev(s));
if(strcmp(t,d)==0)
{
printf("INPUT IS PALINDROME");
}
else
{
printf("INPUT IS NOT PALINDROME");
}
printf("\n\n\--------------------\n\n");
goto l1;
}
String Concat join function in C Language
#include<stdio.h>
#include<conio.h>
#include <string.h>
main()
{
char f[50];
char l[50];
printf("Enter the first name: ");
gets(f);
printf("\nEnter the Last name: ");
gets(l);
strcat(f,l);
puts(l);
}
Copy string from source to destination STRLEN ,STRCPY STRING FUNCTION IN C
#include<stdio.h>
#include<conio.h>
#include <string.h>
main()
{
char source[50];
printf("Enter the string: ");
gets(source);
int x=strlen(source);
char dest[x];
strcpy(dest,source);
printf("\nsource string is: %s ",source);
printf("\nDestination string is: %s ",dest);
}
Thursday, 24 May 2018
List T in C# (GENERIC CLASSES)
class Employee
{
public int id { get; set; }
public string name { get; set; }
}
--------------------------------------------------------------------------
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace ConsoleApplication30
{
class Program
{
static void Main(string[] args)
{
List<Employee> li = new List<Employee>();
Console.WriteLine("How many records you want to add in list:");
int n = int.Parse(Console.ReadLine());
for (int i = 0; i < n; i++)
{
Console.ForegroundColor = System.ConsoleColor.Yellow;
Console.WriteLine("Enter the name: ");
Employee emp = new Employee();
emp.name = Console.ReadLine();
emp.id = i + 1;
li.Add(emp);
Console.ForegroundColor = System.ConsoleColor.Green;
Console.WriteLine("1 RECORDS SUCCESSFULLY INSERTED IN LIST.......");
Console.WriteLine("PRESS ANY KEY.....");
Console.ReadLine();
Console.Clear();
}
Console.WriteLine("PRESS ANY KEY.....");
Console.ReadLine();
foreach (var item in li)
{
Console.ForegroundColor = System.ConsoleColor.Red;
Console.WriteLine("-----------------------------------------------");
Console.ForegroundColor = System.ConsoleColor.Cyan;
Console.WriteLine("ID: "+item.id);
Console.WriteLine("Name: " + item.name);
Console.ForegroundColor = System.ConsoleColor.Red;
Console.WriteLine("-----------------------------------------------");
}
Console.ReadLine();
}
}
}
Collection Classes in C# Generic Classes
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace ConsoleApplication29
{
class Program
{
static void Main(string[] args)
{
string t;
List<string> li = new List<string>();
Console.WriteLine("How many names you want to add in list: ");
int n = int.Parse(Console.ReadLine());
for (int i = 0; i < n; i++)
{
Console.WriteLine("Enter the name: ");
t = Console.ReadLine();
li.Add(t);
Console.ForegroundColor = System.ConsoleColor.Green;
Console.WriteLine("Data successfully added in list.....");
Console.ReadLine();
Console.Clear();
Console.ForegroundColor = System.ConsoleColor.White;
}
Console.ForegroundColor = System.ConsoleColor.Green;
Console.WriteLine("Press any key to print all names");
Console.ReadLine();
foreach (var item in li)
{
Console.ForegroundColor = System.ConsoleColor.Yellow;
Console.WriteLine("name: "+item);
}
Console.ReadLine();
}
}
}
Serialization and Deserialization in C#
C# Serialization
string path = @"C:\Users\salman\Desktop\FILE\serial.doc";
Student s = new Student(1, "Salman");
FileStream stream = new FileStream(path, FileMode.OpenOrCreate);
BinaryFormatter formater = new BinaryFormatter();
formater.Serialize(stream, s);
stream.Close();
Console.ForegroundColor = System.ConsoleColor.Red;
Console.WriteLine("File saved in "+path);
Console.ReadLine();
------------------------------------------------------------------------------
C# Deserialization
string path = @"C:\Users\salman\Desktop\FILE\serial.doc";
FileStream stream = new FileStream(path, FileMode.OpenOrCreate);
BinaryFormatter formater = new BinaryFormatter();
Student s = (Student)formater.Deserialize(stream);
Console.ForegroundColor = System.ConsoleColor.Green;
Console.WriteLine("Id :"+s.id);
Console.WriteLine("Name :" + s.name);
Console.ReadLine();
--------------------------------------------------------------
STUDENT CLASS:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace ConsoleApplication28
{ [Serializable]
class Student
{
public int id;
public string name;
public Student(int id, string name)
{
this.id = id;
this.name = name;
}
}
}
Sunday, 20 May 2018
How to Create folder Directory in C#
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.IO;
namespace ConsoleApplication25
{
class Program
{
static void Main(string[] args)
{
l1:
Console.WriteLine("Enter the folder name :");
string n = Console.ReadLine();
DirectoryInfo DIR = new DirectoryInfo(@"C:\Users\salman\Desktop\FILE\"+n);
try
{
if (DIR.Exists)
{
Console.WriteLine("THIS FOLDER ALREADY EXIST......\nPress any key to go back");
Console.ReadLine();
Console.Clear();
goto l1;
}
else
{
DIR.Create();
Console.Write("fOLDER CREATED.....");
}
}
catch (Exception E)
{
Console.ForegroundColor = System.ConsoleColor.Red;
Console.WriteLine("Folder couldnot be created due to " + E);
}
Console.WriteLine("Enter the folder that u want to delete.......");
n = Console.ReadLine();
new DirectoryInfo(@"C:\Users\salman\Desktop\FILE\" + n);
DIR.Delete();
Console.WriteLine("Folder deleted.....");
Console.ReadLine();
}
}
}
Subscribe to:
Posts (Atom)
Pass Dynamically Added Html Table Records List To Controller In Asp.net MVC
Controller Code: using System; using System.Collections.Generic; using System.Linq; using System.Web; using System.Web.Mvc; using ...
-
Controller Code: using System; using System.Collections.Generic; using System.Linq; using System.Web; using System.Web.Mvc; using ...
-
Load event: pictureBox3.Image = Image .FromFile( @"C:\Users\salman\Documents\Visual Studio 2013\Projects\WindowsFormsApplication3\W...