Private members of a class instance are getting available in Equals() method body

As I override the Equals method of System.Object of C#, I found that the private members of the passed-in parameter were available. For testing purpose, I wrote immediately another test method to see whether it’s only specific to the Equals method or anyone.  As a result, it’s the same.  This is a common phenomenon inside the Class itself. But if I initiate an instance outside of the class, the inner private members are inaccessible.

After looking through the responses in stackoverflow,  I feel that it makes sense. Since the developer is in the class itself,   it is natural that he should have access to anything inside. An analog is that if  you are the designer of  a batch of houses, you know the structure and size of every house. As you do the structural design, you know more than anybody else how to compare two houses by comparing the corresponding rooms.  However, as an outsider, one is innocent about the inner things of the house (when we call the instantiated class outside of the class itself). That is why we can see the private members inside of the class but not outside of class.

Advertisements

Add menu to the front page in wordpress

Every time I wanted to add a menu to the front page, I spent a lot of time exploring. I decided to write it down for preventing the wast of time.

  1. Find the menu
    • Click My Sites, then Customize.
    • In the Customizer, click the Menus tab.
  2. Add menu items
  3. In addition to pages you have already published, you can add several different types of menu items to your custom menu:
    • Page – Adds a link to another page on your site.
    • Link – Adds a custom URL linking to another site.
    • Category – Shows a feed of blog posts from a given category.
    • Tag – Shows a feed of blog posts from a given tag.
    • Post – links directly to a blog post on your site.

In fact, after you have found where the menu setting is, the following becomes easy. For more details, you can refer to wordpress support.

Install pinyin into ubuntu 16.04

  1. Go to System Settings–> Language Support–> Install/Remove Languages, select Chinese(Simplified)
  2. Open the terminal and install the IBus framework with following command:

    sudo apt-get install ibus ibus-clutter ibus-gtk ibus-gtk3 ibus-qt4

  3. Start the IBus framework. In terminal input:

    im-config -s ibus

  4. Install the Pinyin engine

    sudo apt-get install ibus-pinyin

  5. Restart IBus daemon

    ibus restart

  6. Setting the IBus

    ibus-setup

    In the popup window, switch to Input Method tab,click the Add button to choose the Chinese input method installed just now.

  7. Go to the Text Entry (from the right-top corner of the window or from the System Settings -> Text Entry) for the shortcut of input method exchange.

Side note: I came across the following error in this step:

Failed to download package files Check your Internet connection.

For solving it, I did the following:
Press Alt+F2 and type software-properties-gtk.
Change the download location to Main Server or another server close to the country you live in (in my case, it’s already server for Canada by default, so I changed it to Main Server) and do the first step again. Succeed!

After trying above method, I found the chinese input is different from what I get used to use. I decided to install google pinyin. The steps are as follows:

sudo apt-get install fcitx-googlepinyin
im-config

In the windows, click “OK”, then “Yes”, and select fcitx. Click “OK” to confirm and then “OK” to exit.

Now log-out and log-in back. You should see a Keyboard on the top right corner (the task bar of ubuntu in the top).

Click on it you’ll see from the drop-down menu an option ConfigureFcitx . Click on it opening up a panel, where in the Input Method, click the little + button in the bottom to add the method you like. After exploring a bit, I found Sunpinyin is more comfortable for me.

For more details, refer to this post from askubuntu.

Bootstrap’s thumbnails show too much space on both sides of the image in small screen

While using Bootstrap’s thumbnails to display images, I found that while dragging the browser to the small window size, there are too mch space on both sides of the thumbnail.

Before fixing the problem
Look at the white space on both sides of the thumbnail

For fixing it, I change the display property from the default blockto inline-block for the small window size:

In the css style sheet

@media (max-width:992px) {
.thumbnail {display: inline-block;}
}

After the change, the thumbnail shows as follows:

Before fixing the problem
The extra white space inside the gray border disappears.

 

Bootstrap drop-down menu stops pushing content below

I often make my sites with bootstrap. Sometimes I found that the drop-down menu stopped pushing down the content below and stayed above it instead. By looking into my css style sheet, I found it resulted from my setting on the height of the navigation bar. For preventing that from happening, I cannot fix the height of the navigation bar.

Below showed how it happened.

Before the fix:
#menu,
#menu .container,
#menu .container nav
{
height: 57px; // The problem is  caused by this setting
background-color:#240f1e;
}
After the fix:
#menu,
#menu .container,
#menu .container nav
{
 height: 57px; // Remove
margin-bottom: 0; // Add: set the bottom margin to zero instead if you want to adjust the height
background-color:#240f1e;
}