Leave a comment


Extension method vs c#

Leave a comment


public static class Extensions
    public static string GetFirstThreeCharacters(this String str)
        if(str.Length < 3)
            return str;
            return str.Substring(0,3);

<System.Runtime.CompilerServices.Extension> _
Public Function GetFirstThreeCharacters(Byval str As String) As String
If str.Length < 3 Then
	Return str
	Return str.Substring(0, 3)
End If
End Function

oop features in vb6

check oracle version

Leave a comment

what is server version?

select * from v$version;

what is client version?

  sid = sys_context('userenv', 'sid');

use String.Format in javascript like c#

Leave a comment

// This is the function.
		String.prototype.format = function (args) {
			var str = this;
			return str.replace(String.prototype.format.regex, function(item) {
				var intVal = parseInt(item.substring(1, item.length - 1));
				var replace;
				if (intVal >= 0) {
					replace = args[intVal];
				} else if (intVal === -1) {
					replace = "{";
				} else if (intVal === -2) {
					replace = "}";
				} else {
					replace = "";
				return replace;
		String.prototype.format.regex = new RegExp("{-?[0-9]+}", "g");
		// Sample usage.
		var str = "She {1} {0}{2} by the {0}{3}. {-1}^_^{-2}";
		str = str.format(["sea", "sells", "shells", "shore"]);

iis 8.5 issue inetpub do not have permission

Leave a comment

OK, working from memory here as I am not in front of a Windows machine.

If you right click on your webroot folder /inetpub/wwwroot/ or the website directory you are working on open properties and select security, I think it is, you will see the list of users with their permissions for that folder. There is a section to add new users where you can add the IUSR account (search from the list of users if you need to) which will be the default user used when anonymous authentication is enabled. Give this account the relevant permissions (read, write, execute) ensuring you apply to file and subfolders. Refresh the website in IIS and you should hopefully be good to go.

dataset vs collection

Leave a comment

  • DataTable and DataSet are heavy weight comparitively using List Collection.
  • List<Emp> enables you to maintain the safe type. So You no need to do typecasting anytime.
  • It’s prefarable not to use DataSet and DataTable while your data is flowing between the layers as I mentioned in point1
  • Java(any other than .NET languages) can not understand DataSet and DataTable while throwing from WebService or WCF. so it’s easy to convert the List<Emp> to Emp Array and throw it to Java. Java can understand simple clases and arrays.

Best practice – Dispose

Leave a comment

Use built-in keyword in C# as a shortcut for this particular pattern of using
an IDisposable object and calling Dispose when it goes out of scope: the using

// Example use
using (MyClass data = new MyClass())
                    this.Store1.DataSource = data.getData();

public class MyClass : IDisposable
        private object resource1; // pointer for a resource
        private object resource2; // other resource you use
        private bool disposed = false;

        // implements IDisposable
        public void Dispose()

        protected virtual void Dispose(bool disposing)
            if (!this.disposed)
                // if this is a dispose call dispose on all state you
                // hold, and take yourself off the Finalization queue.
                if (disposing)
                    if (resource1 != null)
                        resource1 = null;

                    if (resource2 != null)
                        resource2 = null;
                this.disposed = true;

        // finalizer simply calls Dispose(false)

Older Entries