Menu:

Recent Entries

Categories

Archives

Links

Blogs
- Dflying's Night
- David's Untitled Life
- Dflying's Blog in Chinese

This blog is hosted by DreamHost!

Syndicate

RSS 0.90
RSS 1.0
RSS 2.0
Atom 0.3

C# Basic Interview Questions

Dflying | 31 March, 2006 18:46

  1. What is the implicit name of the parameter passed into a property’s ’set’ method?
    ‘value’. And it’s data type depends on whatever variable we’re changing.
  2. How do you inherit from a class in C#? Place a colon and then the name of the base class.
  3. Does C# support multiple inheritances? No, use interfaces instead.
  4. When you inherit a protected class-level variable, who is it available to? Only classes that ultimately inherit from the class with a protected member can see that member.
  5. Are private class-level variables inherited? Yes, but they are not accessible, so looking at it you can honestly say that they are not inherited. But they are.
  6. Describe the accessibility modifier protected internal. It’s available to derived classes and classes within the same Assembly (and naturally from the base class it’s declared in).
  7. C# provides a default constructor for me. I write a constructor that takes a string as a parameter, but want to keep the no parameter one. How many constructors should I write? Two. Once you write at least one constructor, C# cancels the freebie constructor, and now you have to write one yourself, even if there’s no implementation in it.
  8. What’s the top .NET class that everything is derived from? System.Object.
  9. How’s method overriding different from overloading? When overriding, you change the method behavior for a derived class. Overloading simply involves having a method with the same name within the class.
  10. What does the keyword virtual mean in the method definition? The method can be over-ridden.
  11. Can you declare the override method static while the original method is non-static? No, you can’t, the signature of the virtual method must remain the same, only the keyword virtual is changed to keyword override.
  12. Can you override private virtual methods? No, moreover, you cannot access private methods in inherited classes, have to be protected in the base class to allow any sort of access.
  13. Can you prevent your class from being inherited and becoming a base class for some other classes? Yes, that’s what keyword sealed in the class definition is for. The developer trying to derive from your class will get a message: cannot inherit from Sealed class WhateverBaseClassName. It’s the same concept as final class in Java.
  14. Can you allow class to be inherited, but prevent the method from being over-ridden? Yes, just leave the class public and make the method sealed.
  15. What’s an abstract class? A class that cannot be instantiated. A concept in C++ known as pure virtual method. A class that must be inherited and have the methods over-ridden. Although an abstract class does not require implementations (its methods can be abstract) it can also offer implementations of methods (either virtual or not) which can be called in implementing classes.
  16. When do you absolutely have to declare a class as abstract (as opposed to free-willed educated choice or decision based on UML diagram)? When at least one of the methods in the class is abstract. When the class itself is inherited from an abstract class, but not all base abstract methods have been over-ridden.
  17. What’s an interface class? It’s an abstract class with public abstract methods all of which must be implemented in the inherited classes.
  18. Why can’t you specify the accessibility modifier for methods inside the interface? They all must be public. Therefore, to prevent you from getting the false impression that you have any freedom of choice, you are not allowed to specify any accessibility, it’s public by default.
  19. Can you inherit multiple interfaces? Yes, why not.
  20. And if they have conflicting method names? It’s up to you to implement the method inside your own class, so implementation is left entirely up to you. This might cause a problem on a higher-level scale if similarly named methods from different interfaces expect different data, but as far as compiler cares you’re okay.
  21. What’s the difference between an interface and abstract class? In the interface all methods must be abstract. In the abstract class some methods can be concrete. In the interface no accessibility modifiers are allowed, which is ok in abstract classes.
  22. How can you overload a method? Different parameter data types, different number of parameters, different order of parameters.
  23. What is the difference between const and readonly?
    The const keyword is used for compile time constants while the readonly keyword is used for runtime constants.
  24. What’s the difference between System.String and System.StringBuilder classes? System.String is immutable while System.StringBuilder was designed with the purpose of having a mutable string where a variety of operations can be performed.

Posted in .NET . Comment: (6). Trackbacks:(206). Permalink

Atlas UpdatePanel Tips and FAQs

Dflying | 31 March, 2006 06:28

The first Atlas control a developer may use should be the UpdatePanel, which is really powerful and easy to use. It provides us a closer view of Atlas.

I’ve posted a simple introduction (http://dflying.dflying.net/1/archive/96_introduction_to_atlas_updatepanel.html) to UpdatePanel here and got a lot of questions in the Chinese community. So I think it is better to summarize this kind of questions and answers to a single post about UpdatePanel tips.

 (More)

Posted in Atlas . Comment: (0). Trackbacks:(119). Permalink

Prefer Overrides to Event Handlers in ASP.NET Page

Dflying | 29 March, 2006 06:43

First let’s take a look at two small pieces of code in an ASP.NET code file:

This one is the well known Page_Load() method. Actually it is an event handler which got executed when a Load Event defined in System.Web.UI.Page is fired.

// use event handler
protected void Page_Load(object sender, EventArgs e)
{
    // logic here
}

This one, the OnLoad() method just overrides its base method.

protected override void OnLoad(EventArgs e)
{
    // logic here
    base.OnLoad(e);
}

Though the two methods above can do the same things to initialize your ASP.NET page, I prefer the override way.

 (More)

Posted in ASP.net . Comment: (0). Trackbacks:(198). Permalink

Building a Real Time ProgressBar using ASP.NET Atlas

Dflying | 27 March, 2006 23:44

That will be very cool and useful if you can show your user a ProgressBar on a web page which displays the actual progress of some long operations. Now let’s try to make it possible by using ASP.NET Atlas. This post can also show you some basic conceptions about extending Atlas client side controls. Also, the source code and demo can be downloaded here.

The basic ideas to implement this will be easy. Build an Atlas client side control and query a service to find how much we’ve done every tick. Then get the response and update the UI of progress bar. So in this demo, we separate the code into four parts:

  1. Web Service which processes a time consuming task.
  2. Web Service which is used to query the time consuming task and get the progress.
  3. Client side Atlas ProgressBar control which renders the UI and client side logic. This is the core component of the demo and can also be reused in other pages/projects without any changes.
  4. ASP.NET page contains the Atlas controls and Web Service references, which runs the application.
 (More)

Posted in Atlas . Comment: (26). Trackbacks:(263). Permalink

Web Standard and ASP.NET – Part1 XHTML Quick Start

Dflying | 26 March, 2006 18:47

Web Standard is more and more important in current web based application development. In these series of posts I am going to sharing some of my ideas about how to build Web Standard applications using ASP.NET 2.0.

This post is the first in these series. It introduces some basic XHTML concepts and a quick guide for HTML developers to get familiar with XHTML.

 (More)

Posted in ASP.net . Comment: (0). Trackbacks:(187). Permalink

Introduction to Atlas UpdatePanel

Dflying | 24 March, 2006 20:08

UpdatePanel is so important an Atlas control that connects the traditional ASP.NET application and the new Web 2.0 AJAX implementation. That is, if you own applications wrote by ASP.NET, you do not need to take many changes to get it runs as the cool AJAX way by using UpdatePanel. Or, if you are not familiar with the whole branch of AJAX staffs such as JavaScript/DOM, UpdatePanel provides you a very simple way to use AJAX by warping you dynamic contents in an UpdatePanel, just like the Magic AJAX Framework does.

 (More)

Posted in Atlas . Comment: (0). Trackbacks:(193). Permalink

Tough .NET interview questions

Dflying | 18 March, 2006 18:45

 (More)

Posted in .NET . Comment: (0). Trackbacks:(190). Permalink

Search Engine Friendly URL in LifeType Tag Cloud Plug-in

Dflying | 15 March, 2006 17:14

Currently the Tag Cloud Plug-in of LifeType uses search to fetch related topics and just shows the raw URL such as http://dflying.dflying.net/index.php?searchTerms=ajax&op=Search&blogId=1 which may not friendly enough to search engines. I’ve added a line in .htaccess file

# Search (i.e. /plog/1_userfoo/search/keyword.html)
RewriteRule ^([0-9]+)_[^/]+/search/([^.]+).html$ index.php?
                   blogId=$1&op=Search&searchTerms=$2 [L,NC]

To make the url like http://dflying.dflying.net/1/search/atlas.html. here ‘atlas’ is the keyword.

Then change the plugintagcloud.class.php file line 152 and line 153 to generate friendly urls:

$baseUrl = $rg->getBaseUrl();	
$Cloud .= "<a href='{$baseUrl}/{$blogId}/search/{$k}.html' "
          ."style='font-size: {$size}px; color: #{$r}{$g}{$b}' "
          ."title='$k($v)'>$k</a> &nbsp;&nbsp;";

Just download here if you do not like to modify: http://dflying.dflying.net/1/resources/plugintagcloud.zip.html


Posted in LifeType . Comment: (0). Trackbacks:(1). Permalink

Introduction to Atlas DataTable

Dflying | 15 March, 2006 05:50

Atlas provides Web.Data.DataTable control which is just like the behavior of ADO.NET DataTable object and the Atlas Framework can also make the conversion between the two types for you automatically. Here are some common operations on Atlas DataTable.

Get DataTable from server

Server side code in C#:

[WebMethod]
public DataTable GetDataTable()
{
    DataTable dt = new DataTable();
 
    dt.Columns.Add(new DataColumn("FirstName", typeof(string)));
    dt.Columns.Add(new DataColumn("LastName", typeof(string)));
    dt.Columns.Add(new DataColumn("Email", typeof(string)));
 
    dt.Rows.Add("Dflying", "Chen", "dflying@dflying.net");
    dt.Rows.Add("Someone", "Else", "someone@someone.net ");
 
    return dt;
}

Client side code in JavaScript:

function getDataTable() {
    MyWebService.GetDataTable(onComplete);
}
function onComplete(result) {
    var dataTable = result; 
}

 (More)

Posted in Atlas . Comment: (3). Trackbacks:(191). Permalink

VertrigoServ WAMP Server

Dflying | 14 March, 2006 18:02

Intro

VertrigoServ was developed to make available a highly professional and easily installable package of Apache (HTTP web server), PHP (reflective programming language), MySQL (multithreaded, multi-user, SQL Database Management System), SQLite (ACID-compliant relational database management system), SQLiteManager (multilingual web based tool to manage SQLite database), PhpMyAdmin (tool written in PHP intended to handle the administration of MySQL) and Zend Optimizer (which increases runtime performance up to 40%) for Windows platform. With a convenient all-in-one installer, all components are installed in a single directory and can be used immediately after the installation process has copleted. An uninstaller allows you to remove the VertrigoServ from hard disc. It is designed to be as small and flexible as possible and is therefore highly suitable for internet distribution. VertrigoServ is excellent both for beginners and for advanced users.

Components Page http://vertrigo.sourceforge.net/

Posted in General . Comment: (0). Trackbacks:(98). Permalink

Atlas Drag & Drop Overview

Dflying | 13 March, 2006 04:53

The Atlas framework provides amazing cross-browser support for drag & drop operations. Basically, to create a UI with drag & drop is really simple and we just need:

 (More)

Posted in Atlas . Comment: (1). Trackbacks:(195). Permalink

New Features in ASP.NET 2.0 Page Model

Dflying | 13 March, 2006 01:40

The Attributes of the @Page directive

The @Page directive is the point of control for the developer with some new attributes that have been added to this directive:

  1. Async: If this is set to true, the page class that is generated derives from IHttpAsyncHandler. It adds some built in asynchronous capabilities to the page.
  2. CompileWeb: This attribute specifies the name of the referenced code-beside file to use for the page.
  3. EnablePersonalization: Indicates whether profile information should be used to build the page.
  4. MasterPageFile: This attribute specifies the path of the master to use for building the current page.
  5. PersonalizationProvider: this attribute specifies a valid provider defined in the application’s configuration file.
  6. Theme: specifies the name of the theme to be used.

If Boolean Async directive is used ASP.NET serves up the page in an asynchronous way. The page executes the custom code asynchronously while runtime progresses on the page life cycle. The request threads are synchronized and the output is generated in the browser by setting a single unwind point on the page between PreRender and PreRenderComplete events.

 (More)

Posted in ASP.net . Comment: (0). Trackbacks:(90). Permalink

Why No Banner Ads shown in Atlas Topic?

Dflying | 12 March, 2006 00:49

I've just posted some topics about Atlas but seems no banner ads are shown in the post. I wonder if people do not like ASP.NET? Or something else?

I've checked the keywords of page http://dflying.dflying.net/1/archive/72_extending_the_autocompleteextender_in_atlas.html at https://adwords.google.com/select/KeywordToolExternal and got the result:

 (More)

Posted in General . Comment: (0). Trackbacks:(90). Permalink

Extending the AutoCompleteExtender in Atlas

Dflying | 12 March, 2006 00:20

The recent release of Atlas introduces the concept of ExtenderControls. Extenders are server controls that allow extending a set of ASP.NET server controls by adding client side functionality.

Basically, an ExtenderControl

 (More)

Posted in Atlas . Comment: (0). Trackbacks:(1). Permalink

Atlas Hello World

Dflying | 11 March, 2006 23:42

Let's begin with the classic ‘Hello World!’ example.

The HelloWorld.aspx page has one button. When the button is clicked, data is retrieved from the server and displayed in an alert box.

One of the core features of Atlas is getting data form web server by asynchronous calls. In this example we'll see how to make it, that is, how to retrieve data from the server without doing a traditional ASP.NET PostBack. To do this, we can invoke a server method from client code.

Using Atlas, we can  (More)

Posted in Atlas . Comment: (4). Trackbacks:(281). Permalink

ASP.NET Atlas Overview

Dflying | 11 March, 2006 21:23

Atlas is about Javascript OOP, AJAX, it offers client and server controls, cross-browser compatibility, UI enhancements, it supports flexible binding and a declarative programming style. Atlas integrates the ASP.NET server technology and allows to develop web applications.

At the moment, Atlas is a Preview Technology.

The January release of the Atlas CTP can be downloaded here.

This blog entry by Nikhil Kotari introduces some features of this release, while an Added/Fixed list can be found here.

 (More)

Posted in Atlas . Comment: (0). Trackbacks:(88). Permalink

AJAX with Callback Url and Url Rewriters

Dflying | 10 March, 2006 21:25

The second parameter of the XmlHttpRequest.open method is the Url of the callback page:

xmlRequest.open("GET", url, true);

 (More)

Posted in JavaScript & AJAX . Comment: (0). Trackbacks:(0). Permalink

XmlHttpRequest in IE / FireFox

Dflying | 10 March, 2006 21:22

The XmlHttpRequest object has been introduced in IE 5.5 silently more than 5 years ago, without the AJAX cheerleading and hype we are seeing today. The technology at this point only allowed an ActiveX approach to the problem. A few years later, folks at the Mozilla camp decided to forget their religious and standards based passion and "borrowed" the technology from Microsoft. Since Gecko browsers do not really like ActiveX (which is a good thing), the guys implemented it as a built-in object. Hence now we are having the IE ActiveX XmlHttpRequest vs. the built-in XmlHttpRequest in FireFox. (More)

Posted in JavaScript & AJAX . Comment: (3). Trackbacks:(2). Permalink

XmlHttpRequest – Choose GET or POST?

Dflying | 10 March, 2006 20:24

XmlHttpRequest supports both GET and POST requests to the server, which one should we use? As usual, GET is light and POST is heavy. But I'd say, it really depends on your scenario.

GET requests pass parameters to the server using the query string. So we need to be careful about:

 (More)

Posted in JavaScript & AJAX . Comment: (1). Trackbacks:(4). Permalink

How to View the Dynamic HTML Source

Dflying | 10 March, 2006 20:07

Developing and debugging AJAX apps can be very tricky. The AJAX technology went on relatively soon while the development tools are slow and still catching up, so you do need to use a bag of neat tricks AND dirty/ugly hacks to see what is really going on. The first problem for beginners is where is the HTML output I wrote to the page?

 (More)

Posted in JavaScript & AJAX . Comment: (0). Trackbacks:(92). Permalink

Memory Leak Detector for IE

Dflying | 10 March, 2006 18:38

IE leaks memory, it is a well known fact acknowledged by the Microsoft IE team in their blog and in an article in MSDN ridiculously named Understanding and Solving Internet Explorer Leak Patterns. AJAX callbacks and page updates do not magically workaround this problem - updating the page and scripts on the page after AJAX calls do trigger the "leak patterns" of IE too. If this turns out to be a problem in your application, the best starting point is (as usual) quirksmode.org.

Here comes the Drip tool at http://www.outofhanwell.com/ieleak/. The must-have tool is a nifty little utility that starts your web-page, detects leaks and shows details for each leak.

 (More)

Posted in JavaScript & AJAX . Comment: (0). Trackbacks:(0). Permalink

JavaScript Variable Scope

Dflying | 10 March, 2006 17:39

In JavaScript, there's a 'wired' feature that the variable scope is only the function. For example, in the following code:

var i = 1;
{
    var i = 2;
}
alert(i);

You will get 2 alerted. That's really interesting and everyone should pay more attention to.


Posted in JavaScript & AJAX . Comment: (0). Trackbacks:(97). Permalink

Access Denied Error in Rich Text Editor after Adding Google Adsence Ad

Dflying | 06 March, 2006 00:42

When showing Google Adsence Ads in your LifeType Admin page, you may get the ‘Access Denied’ JavaScript error when choosing a resource or image. I’ve debugged into the JavaScript code today and find some potential conflicts between the editor and Adsence Ad. The editor is trying to visit elements generated by the Ad in different domains (google.com), so IE denied the access.

 (More)

Posted in LifeType . Comment: (6). Trackbacks:(10). Permalink

ASP.NET Free Hosting

Dflying | 05 March, 2006 18:41

I've got some info about ASP.NET Free Hosting providers, listed below... Pick one as you wish, but, just have a try... (More)

Posted in General . Comment: (1). Trackbacks:(190). Permalink

Google Adsence Statistics Tool

Dflying | 03 March, 2006 22:26

Google Adsence page do not provide detailed statistics, e.g. when your ads are clicked, where is the clicker's IP, what ad does he/she clicked or which page the clicked ad is placed.

We could simply use some client and server site script to record these data for your infomation. I'd like to choose Javascript and PHP to make it.

 (More)

Posted in General . Comment: (4). Trackbacks:(97). Permalink

Code Snippet of Visual Studio 2005

Dflying | 02 March, 2006 01:44

I’ve just tried out a very cool new feature of Microsoft Visual Studio 2005 (also available in Visual Web Developer) – the “Code Snippet”, it is some kind of like a clipboard where you can store your common patterns or code there.

I’ve downloaded the Math Code Snippets from MSDN and installed in “My Code Snippets” directory.

 (More)

Posted in .NET . Comment: (10). Trackbacks:(101). Permalink

About Google Adsence

Dflying | 01 March, 2006 02:08

Google Adsence is so popular a kind of ads on the web now. You may find the banners titled “Ads by Google” everywhere on the Internet. After weeks searching and trying, I’ve come out some rules for the one who wants to get money from Google:

 (More)

Posted in General . Comment: (0). Trackbacks:(98). Permalink