Thursday, October 6, 2016

lambda expression in C#

A lambda expression is an anonymous function means no name of method. The => token is called the lambda operator. It is used in lambda expressions to separate the input variables on the left side from the lambda body on the right side.


Example
delegate int del(int i);
static void Main(string[] args)
{
    del myDelegate = x => x * x;
    int my = myDelegate(5); //my = 25
}


Example 2:

        public static void Main()
        {
            Func<int, int> t = x => x + 1;

            Func<int, int> t2 = x => { return x + 1; };

            Func<string, string> t3 = x => { return x; };

            Action<int> example1 =  (int x) => Console.WriteLine("{0}", x);
       
       
            Console.WriteLine(t.Invoke(1));
            example1.Invoke(7);
            Console.ReadLine();
        }
Output : 2
               7

Using hashtags on Instagram

How do I use hashtags?

You can add hashtags in the caption or comments of your post. If you add hashtags to a post that's set to public, the post will be visible on the corresponding hashtag page.


To tag a photo or video with a hashtag:

1. Take or upload a photo or video
2. Choose to add a filter, then type # followed by text or emoji in the Caption field (ex: #flower)
3. If you want to add a hashtag to a post you've already uploaded, edit the caption or include your hashtag in a comment on your photo

After you tag your post with a hashtag, you'll be able to tap the hashtag to see a page that shows all photos and videos people have uploaded with that hashtag.

Things to keep in mind:

  • When people with private profiles tag posts, they won't appear publicly on hashtag pages.
  • Numbers are allowed in hashtags. However, spaces and special characters, like $ or %, won't work.
  • You can only tag your own posts. You can't tag other people's photos/videos.
  • You can use up to 30 tags on a post. If you include more than 30 tags on a single photo/video, your comment won't post.
  • Older versions of Apple IOS don't support tapping hashtags. Instead, search hashtags by going to  Search & Explore > Search > Tags.


How can I change the phpmyadmin automatic log out time?

In PHPMyAdmin 4 this no longer appears in the config.inc.php file. Instead go to PHPMyAdmin in your browser. Ensure you are at the localhost level to see the Settings link. Then set Settings > Features > Change the value of 'Login cookie validity' > Save

Tuesday, October 4, 2016

Hide my likes and comments from my friends on Facebook?

Add the friends you want to prevent from seeing your comments to your acquaintances’ list, this way they will remain your friends, but you may opt for sharing posts with “friends except acquaintances “.
You can edit your lists (add or remove people) 

Monday, October 3, 2016

Shallow copy and Deep copy in C#

Shallow copy and Deep copy:

Shallow Copy :Shallow copy copies the reference of that class or object and its don't create new memory to copy the object.

Example:

public MyClass ShallowCopy()
    {
        return (MyClass)this.MemberwiseClone();
    }
/////////////////////////////////////////////////////////////////////////

 class A
    {
        public int a = 0;
        public void display()
        {
            Console.WriteLine("The value of a is " + a);
        }
    }

    class Program
    {
        static void Main(string[] args)
        {
            A ob1 = new A();
            ob1.a = 10;
            A ob2 = new A();
            ob2 = ob1;
            ob1.a = 5; // <-- If you see value of ob2.a after this line, it will be 5.
            ob2.display();
            Console.ReadLine();
        }
    }

Output : The value of a is 5
/////////////////////////////////////////////////////////
Deep Copy: copies not only copies the value type but also provide a new memory object with new refrance for refrance type member in the new copy class.

Example:

 public MyClass DeepCopy()
    {
        MyClass temp = (MyClass)this.MemberwiseClone();
        //Creating a new memory for the object and setting same values from the original
        temp.myjob = new Job { Department = this.myjob.Department, job = this.myjob.job };
        return temp;
    }

 class A
    {
        public int a = 0;
        public void display()
        {
            Console.WriteLine("The value of a is " + a);
        }
    }

    class Program
    {
        static void Main(string[] args)
        {
            A ob1 = new A();
            ob1.a = 10;
            A ob2 = new A();
            ob2.a = ob1.a;

            ob1.a = 5; // <-- If you see value of ob2.a after this line, it will be 10.
            ob1.display();
            ob2.display();
            Console.ReadLine();
        }
    }

OutPut : The value of a is 5
              The value of a is 10

       

Sunday, October 2, 2016

Create table in SQL Server - Syntax

Create table in SQL Server - Syntax

It is very simple to create table in sql server. Create table syntax is used to create table in sql server. Tables in sql server contains columns an rows which contains records. 

Syntax - 

Create Table TableName
(
ColumnName1 data_type(size) Primary Key,
ColumnName2 data_type(size) NOT NULL,
ColumnName3 data_type(size) NOT NULL,
ColumnName4 data_type(size) NOT NULL,
......
......
);

Here, the ColumnName1, ColumnName2 , ColumnName3 and  ColumnName4 specifies the name of column in table, data_type specifies the type of  the record that column holds, size specifies the maximum length of the column in table and NOT NULL means column does not hold null value.

For example -

CREATE TABLE Employees
(
  Emp_Id  INT PRIMARY KEY,
  First_Name VARCHAR(50),
  Last_Lame VARCHAR(50) NOT NULL,
  Salary MONEY
);