Friday, May 30, 2008

C# InterView Questions....

  • What’s the advantage of using System.Text.StringBuilder over System.String? StringBuilder is more efficient in the cases, where a lot of manipulation is done to the text. Strings are immutable, so each time it’s being operated on, a new instance is created.
  • Can you store multiple data types in System.Array? No.

  • What’s the difference between the System.Array.CopyTo() and System.Array.Clone()? The first one performs a deep copy of the array, the second one is shallow.

  • How can you sort the elements of the array in descending order? By calling Sort() and then Reverse() methods.

  • What’s the .NET datatype that allows the retrieval of data by a unique key? HashTable.


  • What’s class SortedList underneath? A sorted HashTable.

  • Will finally block get executed if the exception had not occurred? Yes.

  • What’s the C# equivalent of C++ catch (…), which was a catch-all statement for any possible exception? A catch block that catches the exception of type System.Exception. You can also omit the parameter data type in this case and just write catch {}.

  • Can multiple catch blocks be executed? No, once the proper catch code fires off, the control is transferred to the finally block (if there are any), and then whatever follows the finally block.

  • Why is it a bad idea to throw your own exceptions? Well, if at that point you know that an error has occurred, then why not write the proper code to handle that error instead of passing a new Exception object to the catch block? Throwing your own exceptions signifies some design flaws in the project.


  • What’s a delegate? A delegate object encapsulates a reference to a method. In C++ they were referred to as function pointers.

  • What’s a multicast delegate? It’s a delegate that points to and eventually fires off several methods.

  • How’s the DLL Hell problem solved in .NET? Assembly versioning allows the application to specify not only the library it needs to run (which was available under Win32), but also the version of the assembly.

  • What are the ways to deploy an assembly? An MSI installer, a CAB archive, and XCOPY command.

  • What’s a satellite assembly? When you write a multilingual or multi-cultural application in .NET, and want to distribute the core application separately from the localized modules, the localized assemblies that modify the core application are called satellite assemblies.

  • What namespaces are necessary to create a localized application? System.Globalization, System.Resources.


  • What’s the difference between // comments, /* */ comments and /// comments? Single-line, multi-line and XML documentation comments.

  • How do you generate documentation from the C# file commented properly with a command-line compiler? Compile it with a /doc switch.

  • What’s the difference between <c> and <code> XML documentation tag? Single line code example and multiple-line code example.

  • Is XML case-sensitive? Yes, so <Student> and <student> are different elements.


  • What debugging tools come with the .NET SDK? CorDBG – command-line debugger, and DbgCLR – graphic debugger. Visual Studio .NET uses the DbgCLR. To use CorDbg, you must compile the original C# file using the /debug switch.

  • What does the This window show in the debugger? It points to the object that’s pointed to by this reference. Object’s instance data is shown.

  • What does assert() do? In debug compilation, assert takes in a Boolean condition as a parameter, and shows the error dialog if the condition is false. The program proceeds without any interruption if the condition is true.

  • What’s the difference between the Debug class and Trace class? Documentation looks the same. Use Debug class for debug builds, use Trace class for both debug and release builds.

  • Why are there five tracing levels in System.Diagnostics.TraceSwitcher? The tracing dumps can be quite verbose and for some applications that are constantly running you run the risk of overloading the machine and the hard drive there. Five levels range from None to Verbose, allowing to fine-tune the tracing activities.

  • Where is the output of TextWriterTraceListener redirected? To the Console or a text file depending on the parameter passed to the constructor.


  • How do you debug an ASP.NET Web application? Attach the aspnet_wp.exe process to the DbgClr debugger.

  • What are three test cases you should go through in unit testing? Positive test cases (correct data, correct output), negative test cases (broken or missing data, proper handling), exception test cases (exceptions are thrown and caught properly).

  • Can you change the value of a variable while debugging a C# application? Yes, if you are debugging via Visual Studio.NET, just go to Immediate window.

  • Explain the three services model (three-tier application). Presentation (UI), business (logic and underlying code) and data (from storage or other sources).

  • What are advantages and disadvantages of Microsoft-provided data provider classes in ADO.NET? SQLServer.NET data provider is high-speed and robust, but requires SQL Server license purchased from Microsoft. OLE-DB.NET is universal for accessing other sources, like Oracle, DB2, Microsoft Access and Informix, but it’s a .NET layer on top of OLE layer, so not the fastest thing in the world. ODBC.NET is a deprecated layer provided for backward compatibility to ODBC engines.

  • What’s the role of the DataReader class in ADO.NET connections? It returns a read-only dataset from the data source when the command is executed.


  • What is the wildcard character in SQL? Let’s say you want to query database with LIKE for all employees whose name starts with La. The wildcard character is %, the proper query with LIKE would involve ‘La%’.

  • Explain ACID rule of thumb for transactions. Transaction must be Atomic (it is one unit of work and does not dependent on previous and following transactions), Consistent (data is either committed or roll back, no “in-between” case where something has been updated and something hasn’t), Isolated (no transaction sees the intermediate results of the current transaction), Durable (the values persist if the data had been committed even if the system crashes right after).

  • What connections does Microsoft SQL Server support? Windows Authentication (via Active Directory) and SQL Server authentication (via Microsoft SQL Server username and passwords).

  • Which one is trusted and which one is untrusted? Windows Authentication is trusted because the username and password are checked with the Active Directory, the SQL Server authentication is untrusted, since SQL Server is the only verifier participating in the transaction.

  • Why would you use untrusted verificaion? Web Services might use it, as well as non-Windows applications.

  • What does the parameter Initial Catalog define inside Connection String? The database name to connect to.


  • What’s the data provider name to connect to Access database? Microsoft.Access.

  • What does Dispose method do with the connection object? Deletes it from the memory.

  • What is a pre-requisite for connection pooling? Multiple processes must agree that they will share the same connection, where every parameter is the same, including the security settings.
  • Read C# in more descriptive and easy way

    1: Introduction to C# , 2: Introduction to Variables , 3: Using Variables , 4: Introduction to Classes , 5: C# and Code Organization , 6: Data Reading/Formatting , 7: The Methods of a Class , 8: Combinations ofClasses , 9: Introduction to Conditions , 10:Conditional Statements , 11:Conditional Switches , 12:Counting and Looping , 13:The Properties of a Class , 14: Inheritance , 15:Polymorphism/Abstraction , 16:Delegates , 17:Structures , 18: Built-In Classes , 19: Introduction to Exceptions , 20: Using Exceptions , 21: Introduction to Arrays , 22: Arrays and Classes , 23: Multidimensional Arrays , 24: The Array Class , 25: Strings , 26: Introduction to Indexers , 27: Classes and Indexers , 28: Introduction to Collections , 29: Iterating a Collection , 30: Intro to Collection Classes , 31: Generics , 32: Intro to File Processing , 33: Details on File Processing , 34: Files Operations , 35: Serialization , 36: Querying a List

    Read c#.net in more descreptive and easy way..

    1:  Introduction to C# , 2:  Introduction to Variables , 3:  Using Variables , 4:  Introduction to Classes , 5:  C# and Code Organization , 6:  Data Reading/Formatting , 7:  The Methods of a Class , 8:   Combinations ofClasses , 9:  Introduction to Conditions , 10:Conditional Statements , 11:Conditional Switches , 12:Counting and Looping , 13:The Properties of a Class , 14: Inheritance , 15:Polymorphism/Abstraction , 16:Delegates , 17:Structures , 18: Built-In Classes , 19: Introduction to Exceptions , 20: Using Exceptions , 21: Introduction to Arrays , 22: Arrays and Classes , 23: Multidimensional Arrays , 24: The Array Class , 25: Strings , 26: Introduction to Indexers , 27: Classes and Indexers , 28: Introduction to Collections , 29: Iterating a Collection , 30: Intro to Collection Classes , 31: Generics , 32: Intro to File Processing , 33: Details on File Processing , 34: Files Operations , 35: Serialization , 36: Querying a List

    To read more Jokes......

    1. The Smiths were unable to conceive children and decided...
    2. A guy was trying to console a friend...
    3. A hundred prostitutes in Washington D.C. were asked...
    4. An old man was critically ill...
    5. Little Johnny catches his parents going at it...
    6. A man walks into a pharmacy, buys a condom...
    7. A guy steps into an elevator and...
    8. Soft and Hard
    9. Whats the difference between a blond and a Mosquito?
    10. A beautiful, voluptuous woman went to a gynecologist...
    11. Pray hard
    12. Charlie was in a bar and three babes came up and...
    13. What is the definition of ultimate rejection?
    14. A penis study
    15. Fortunate ingenuity
    16. A woman accompanied her husband to the doctors office...
    17. Excuse TO smoke
    18. A beautiful, voluptuous woman goes to a gynecologist...
    19. Twice a day
    20. Proffessional Terms
    21. A new way to loose weight
    22. A guy was sitting in a bar when a stranger...
    23. The Perfect Worker
    24. No $
    25. Little Gregory wakes up in the middle of the night...
    26. How does Michael Jackson pick his nose?
    27. This man was having problems getting it up to have sex...
    28. True love
    29. There was this boy in high school that was what you would call...
    30. Good News, Bad News, Worse News VII

    31. Little Johnny was in his math's class one day...
    32. One day, a young cowboy and a cowgirl decided...
    33. A guy is screwing a great looking blonde...
    34. A little boy was excited about his first day at school...
    35. A horny young man went to a brothel...
    36. An infamous stud with a long list of conquests...
    37. Appropriate punishment
    38. Why I Fired My Secretary
    39. A man wonders if having sex on the Sabbath is a sin...
    40. Paying Rent
    41. A little girl was walking along a beach in California...
    42. A clear moral
    43. A horrible curse
    44. Nauseous sex
    45. It's dark in here
    46. What did the hurricane say to the coconut tree?
    47. Ed, Ted and their wives went out camping one weekend...
    48. Trouble with the car
    49. The Seven Most Important Men in a Woman's Life
    50. Beep-beep
    51. The subway car was packed...
    52. I HAD A BAD DAY
    53. What is the most insensitive part of a penis?
    54. Golf lessons
    55. What do you do if a blond throws a grenade at you?
    56. A unit in sex education was about to begin...
    57. This guy unexpectedly got the day off and decided...
    58. On a very cold winter night...
    59. A teacher, a garbage collector, and a lawyer wound up together at the Pearly Gates...
    60. On their first night to be together...
    61. A man moves into a nudist colony...
    62. Working With The FBI
    63. A farmer and his wife were laying in bed one night...
    64. The same thing
    65. Communication problem
    66. A dubious remedy
    67. Brand new
    68. A middle manager is called into his bosses office...
    69. Jane was a first time contestant on the $65,000 quiz show...
    70. All the same
    72. Some people are sitting in a bar...
    73. Crazy Sally went to her gynecologist...
    74. A group of Americans was touring Ireland...
    75. Stuttering animal
    76. Two law partners leave their office and go to lunch...
    77. A man was being interviewed for a job...
    78. A convincing lesson
    79. Clinton died and was standing at hte Pearly Gates...
    80. Cheap widow
    81. A marine general, an army general and a navy admiral...
    82. What do you call a gay bar that has no chairs?
    83. Golfing
    84. The medical student was asked four reasons...
    85. An old man and an old woman were sitting...
    86. The three wishes
    87. The price decides everything
    88. Peanuts
    89. Chanowski & his other Polak drinking buddy are sitting...
    90. Sue and Sally meet at their 30th class reunion...
    91. I went past a plastic surgeon's shop...
    92. George W. Bush was passing through an airplane terminal...
    93. Merry...ied talk
    94. Bad news
    95. A state trooper pulled a car over...
    96. Great A Hot & Juicy Story
    97. Two Tourists
    98. Punishment that fits the crime
    99. Blondes dumb?!?!?
    100. One day a blonde went into Wal-Mart and...

    Tuesday, May 20, 2008

    To get more information of Java script use bellow link...

    To get Java script more information use bellow given link.
    http://jennifermadden.com/javascript/stringSubstring.html

    How to visible or invisible controls through Java Script....

    You can visible or invisible controls with two different ways-
    1) var control;
    control=document.getElementById("controlId");
    control.style.display="none";
    control.style.display="block";

    2) var control;
    control=document.getElementById("controlId");
    control.style.visibility="visible";
    control.style.visibility="hidden";

    first one work with IE,Netscape,Mozila,etc. smoothely.
    second one work with IE only.

    Thursday, May 15, 2008

    What is the % Code in My URL?

    In order to prevent the misinterpretation of special characters such as a space, bracket (<>), or % in the URL (which stands for Uniform Resource Locator - it is the address you see in your browser's address bar indicating the location of the website you are visiting), browsers parse certain special characters using escape characters. This explains why when you click on a link such as: domain.com/page one.htm you see it parsed in the address bar as domain.com/page%20one.htm. In this case the %20 is the escape character for the space.
    Common URL Escape Characters
    Table of URL Escape Characters
    Character Escape Character Character Escape Character
    Space %20 # %23
    $ %24 % %25
    & %26 @ %40
    ' %60 / %2F
    : %3A ; %3B
    < %3C = %3D
    > %3E ? %3F
    [ %5B \ %5C
    ] %5D ^ %5E
    { %7B %7C
    } %7D ~ %7E

    SQL string split function

    This can't be the best SQL string split function around, and it's the 3rd string split function I've borrowed to solve a problem. To stop spaghetti creep, I've got to choose one and go with it.I could pick one of the 3 string split functions I'm using, but maybe if I poll the community at large with a large pole I'll find some string split function out there that's better than sliced bread.
    CREATE FUNCTION dbo.Split
    ( @RowData nvarchar(2000), @SplitOn nvarchar(5))
    RETURNS @RtnValue table
    ( Id int identity(1,1), Data nvarchar(100))
    AS
    BEGIN
    Declare @Cnt int
    Set @Cnt = 1
    While (Charindex(@SplitOn,@RowData)>0)

    Begin
    Insert Into @RtnValue (data)
    Select Data = ltrim(rtrim(Substring(@RowData,1,Charindex(@SplitOn,@RowData)-1)))
    Set @RowData = Substring(@RowData,Charindex(@SplitOn,@RowData)+1,len(@RowData))

    Set @Cnt = @Cnt + 1
    End
    Insert Into @RtnValue (data)
    Select Data = ltrim(rtrim(@RowData))
    Return

    END

    Regular Expressions and C#, .NET

    This Article explores the concept of Regular Expressions in the context of C#, .NET support for Regular
    Expressions, Meta-characters and their Description, Character Escapes, Substitutions, Character Classes, Regular Expression Options and Atomic Zero-Width Assertions.

    What are regular expressions?
    Regular expressions are Patterns that can be used to match strings. You can call it a formula for matching strings that follow some pattern. Regular expression(s) can be considered as a Language, which is designed to manipulate text. You can then ask questions such as
    “Does the given string match the pattern?”, or “Does the given string contain characters that match a pattern?”. Regular Expressions may be used to find one or more occurrences of a pattern of characters within a string. You may choose to replace it with some other characters or perform some other tasks based on the results obtained. These patterns of characters can be simple or very complex. Regular Expressions generally comprises of two types of characters –
    1) Literal or Normal Characters such as “abcd123” 2) Special Characters that have a special meaning such as “.” Or “$” or “^”
    Due to the special characters Regular Expressions form a very powerful means of manipulating strings and text.

    .NET support for Regular Expressions:
    .Net provides an extensive set of Regular expressions which you could use to create, modify or compare strings. They can be classified as follows –
    a) Character Escapes b) Substitutions c) Character Classes d) Regular Expression Options e) Atomic Zero-Width Assertions f) Quantifiers g) Grouping Constructs h) Backreference Constructs i) Alternation Constructs j) Miscellaneous Constructs

    Split the String values with a special character in MS Flow to convert this into Array

     Many times we have a requirement to prepare the Mailing address for some of the documents, suppose there are Address Line1, Address Line2, ...