Codechef4u is a community for computer professionals,by computer professionals,just like you; who loves sharing and helping each others,Join them
Share your post

Unsafe Keyword

Can we use pointer in C# this question frequently asked by beginner level C# programmer, yes there are some situations we require that.

The unsafe keyword denotes an unsafe context, which is required for any operation involving pointers.

Pointers in C# we use with below situations:

1. Dealing with existing structures on disk
2.  Advanced COM or Platform Invoke scenarios that involve structures with pointers in them
3. Performance-critical code

Frequently this is used with unmanaged code in C# , for example you want to write code for image data.

Syntax:

unsafe
{
 
// unsafe context: can use here unmanaged code  or pointer code.
 
}

Method:

unsafe static void sammpleMethod(unmanaged paramter 1,unmanaged parameter2,unmanaged paramter n..)
{
   // Unsafe context: can use pointers here.
}

Example:

namespace UnsafeExample
{
   class Program
   {
      public static void Main()
      {
         unsafe
         {
            int var = 50;
            int* p = &var;
            Console.WriteLine("value is: {0} " , var);
            Console.WriteLine("value is: {0} " , p->ToString());
            Console.WriteLine("Address is: {0} " , (int)p);
         }
        
         Console.ReadKey();
      }
   }
}

Example with block:

 unsafe
{
    // whole block code is considered as unsafe
    BitmapData bmData = testbm.LockBits(...)
    byte *bits = (byte*)pixels.ToPointer();
    // Do stuff with bits
}
        }

Base Keyword

Base Keyword

In C# base keyword is used to call the base class constructor and base class members (field, property, method etc.) that has been overridden or hidden in the current class.

Example with base method:

    class Collage
    {
        protected virtual void StudentInfo()
        {
            
        {
            Console.WriteLine("I'm Collage");
        }
    }
 
    
        }
    }
 
    class Department : Collage
    {
        protected override void StudentInfo()
        {
            
        {
            Console.WriteLine("I'm Department");
        }
 
        
        }
 
        public void Bar()
        {
            StudentInfo();
            
        {
            StudentInfo();
            base.StudentInfo();
        }
}
        }
}



 Base Class Constructor:

    public class Father
    {
        int num;
 
        
 
        public Father()
        {
            
        {
            Console.WriteLine("Indian origin peoplr");
        }
 
        
        }
 
        public Father(String Address)
        {
 
            
        {
 
            Console.WriteLine("Contact Information:" + Address);
        }
 
        
        }
 
        public int GetNum()
        {
            
        {
            return num;
        }
    }
 
    
        }
    }
 
    public class Son : Father
    {
        // This constructor will call Father.Father()
        public Son()
            : 
            : base()
        {
        }
 
        
        {
        }
 
        // This constructor will call Father.Father(String Address)
        public Son(string  address)
            : 
            : base(address)
        {
            
        {
            Console.WriteLine("My Birth location is :Latur,Mahrashtra");
        }
 
        
        }
 
        static void Main()
        {
            
        {
            Son Son = new Son();
            
            Son Son1 = new Son(1);
        }
}
        }
}    


Points to remember:

    Base keyword is not allowed in static method and static class.

 

User acceptance testing (UAT)

In this article I will explain user acceptance testing; my whole work experience is in software development still I will try to share knowledge and team experience on this topic.

User acceptance testing (UAT) Defination:

User acceptance testing (UAT) is testing by some specific end users on beta release or pre release version.

Possible end users are:

1.  Specific Company Employees
2.  Specific users from Customer
3.  Common users.
End users checks software meets a set of agreed acceptance criteria and UAT validates software is
Fit for deployment or release.

This is performed after the ST, SIT or in parallel to them.

Example:

Weekly or monthly worksheet and work tracking application , testing of the tracking application by a select group of employees of the organization to validate if the system meets their actual business needs is an example for User Acceptance Testing.

    In this testing employees can create time-sheet for week, Month, create projects and save daily work details. Employees can check their work hour reports, their attendance with this application.