Wednesday, April 20, 2016

Question Answer

1. C# class can inherit multiple ________
Ans: Interface
2. Which of the followings are value types in C#?
Ans: 
  1. Int32
  2. Double
  3. Decimal
3. Which of the following is a reference type in C#?
Ans: String
4. What is Nullable type?
Ans: It allows assignment of null to value type.
5. Struct is a _____.
Ans: Value type
6. 10 > 9 ? “10 is greater than 9” : “9 is greater than 10” is an example of _______
Ans: Ternary operator
7. Which of the following datatype can be used with enum?
Ans: Int
8. What is indexer?
Ans: It allows an instance of a class to be indexed like an array
9. String data type is ______.
Ans: Immutable
10. An array in C# starts with _____ index.
Ans: Zero
11. Which of the following is right way of declaring an array?
Ans: Int[] intArray = new int[5];
12. Which of the following is true for ReadOnly variables?
Ans: Value will be assigned at runtime.
13. Which of the following statement is true?
Ans: 
  1. try block must be followed by catch and finally block.
  2. try block must be followed by catch or finally block or both.
  3. try block can include another try block.
14. Which of the following statement is true?
Ans: A finally block cannot include return or break keyword.
15. Func and Action are the types of ______.
Ans: Delegate
16. Return type of Predicate <T>() is always a ______.
Ans: Boolean
17. A partial class allows ________
Ans: Implementation of single class in multiple .cs files.
18. LINQ stands for ________.
Ans: Language Integrated Query
19. Data type of a variable declared using var will be assigned at _______.
Ans: Compile time
20. Which of the following is true for dynamic type in C#?
Ans: It escapes compile time type checking

Monday, April 11, 2016

CASE IN in SQL

SELECT CASE WHEN ASL_COLLECT.TRANSFOR ='BILL' THEN 'BILL' WHEN ASL_COLLECT.TRANSFOR ='ADV'
THEN 'ADVANCE' WHEN ASL_COLLECT.TRANSFOR IN ('MFEE','MAINTENANCE FEE') THEN 'MAINTENANCE FEE' END AS TRANSFOR FROM ASL_COLLECT

Thursday, April 7, 2016

Select Tomorrow or Yesterday in C#


DateTime tomorrow = DateTime.Now.AddDays(1);
DateTime yesterday = DateTime.Now.AddDays(-1);

Wednesday, April 6, 2016

Displaying dropdown list in ASP.NET MVC

In a view page: like index.cshtml

@using ProjectName.Models
@model ProjectName.Models.DTO.CBDTO
@{
List<SelectListItem>listcabintype=new List<SelectListItem>();
    listcabintype.Add(new SelectListItem{Text="PATIENT",Value = "PATIENT"});
    listcabintype.Add(new SelectListItem { Text = "RELATIVE", Value = "RELATIVE" });

}

....your needed links here...

@using (Html.BeginForm())
{
      ............................Your code................

 @Html.DropDownListFor(model => model.CabinType, listcabintype,new {  @class = "form-control input-sm", id = "CabinType" })


..........................................Code..................
}

Monday, April 4, 2016

Left Outer join by LINQ

 var opd_data = (from t1 in db.HMS_OPD
                         join t2 in db.HMS_OPDMST on t1.PATIENTYYID equals t2.PATIENTYYID
                         join t3 in db.HMS_HEADIO on t1.BILLID equals t3.HEADID
                         join t4 in db.HMS_TEST on t1.TESTID equals t4.TESTID
                        into ps from t4 in ps.DefaultIfEmpty()
 where t1.COMPID == compid && t1.TRANSDT == fdate && t1.PATIENTYYID == patientyid &&
                                        (t1.TESTID == t4.TESTID || t1.TESTID == null)
                                        select new
                                        {
                                            Id = t1.ID,

                                            compid = t1.COMPID,
                                            Transdate = t1.TRANSDT,
                                            Patientid = t1.PATIENTID,
                                            Patientyid=t1.PATIENTYYID,
                                            referid = t1.REFERID,
                                            billid=t1.BILLID,
                                            billname = t3.HEADNM,
                                            testsl = t1.TESTSL,
                                            tcatid = t1.TCATID,
                                         
                                            testid = t1.TESTID,
                                            testname = t4.TESTNM,
                                            amount = t1.AMOUNT,
                                            pcntr = t1.PCNTR,
                                            pcntd = t1.PCNTD,
                                            discr = t1.DISCR,
                                            remarks = t1.REMARKS


                                        });

                        foreach (var item in opd_data)
                        {
                            string testnm = "";
                            if (item.testid == null)
                            {
                                testnm = "";
                            }
                            else
                            {
                                testnm = item.testname;
                            }
                            yield return new OpdDTO
                            {
                                ID = item.Id,
                                COMPID = item.compid,
                                PatientName = PatientName,
                                TransactionDate = Convert.ToString( item.Transdate),
                             
                                PatientID = item.Patientid,
                                PatientYearID = Convert.ToInt64(item.Patientyid),
                                ReferID = item.referid,
                                TestSerial = item.testsl,
                                BillId = item.billid,
                                Billname = item.billname,
                                TestCategoryId = item.tcatid,
                                //TestCategoryName = item.tCatname,
                                TestID = item.testid,
                                TestName =testnm,
                                Amount = item.amount,
                                Pcntd = item.pcntd,
                                Pcntr = item.pcntr,
                                Discr = item.discr,
                                Remarks = item.remarks

                            };
                        }

Saturday, April 2, 2016

Updating data in ASP.NET MVC

  var ache_kina_data = (from n in db.dbSetName where n.COMPID == compid && n.TRANSNO == TransNo select n).ToList();

 foreach (var otMaster in ache_kina_data)
                {

                    otMaster.ID = otMaster.ID;
                    otMaster.COMPID = otMaster.COMPID;
                    otMaster.TRANSDT = otMaster.TRANSDT;
                    otMaster.TRANSYY = otMaster.TRANSYY;
                    otMaster.TRANSNO = otMaster.TRANSNO;

                 
                    otMaster.OPTMFR = timefrom;
                    otMaster.OPTMTO = timeto;
                    otMaster.REMARKS = remarks;
                 

                   

                }
                db.SaveChanges();


Interview Question/Answer Version 1

1. What is the full form of OOPS?
Ans: Object Oriented Programming System.
2. What is a class?
Ans: Class is a blue print which reflects the entities attributes and actions. Technically defining a class is designing an user defined data type.
3. What is an Object?
Ans: An instance of the class is called as object.
4. List the types of inheritance supported in C++
Ans:Single, Multilevel, Multiple, Hierarchical and Hybrid.
5. What is the role of protected access specifier?
Ans: If a class member is protected then it is accessible in the inherited class. However, outside the both the private and protected members are not accessible.
6. What is encapsulation?
Ans: The process of binding the data and the functions acting on the data together in an entity (class) called as encapsulation.
7. What is abstraction?
Ans: Abstraction refers to hiding the internal implementation and exhibiting only the necessary details.
8. What is inheritance?
Ans: Inheritance is the process of acquiring the properties of the existing class into the new class. The existing class is called as base/parent class and the inherited class is called as derived/child class.
9. Explain the purpose of the keyword volatile.
Ans: Declaring a variable volatile directs the compiler that the variable can be changed externally. Hence avoiding compiler optimization on the variable reference.
10. What is an inline function?
Ans: A function prefixed with the keyword inline before the function definition is called as inline function. The inline functions are faster in execution when compared to normal functions as the compiler treats inline functions as macros.
11. What is a storage class?
Ans: Storage class specifies the life or scope of symbols such as variable or functions.
12. Mention the storage classes names in C++.
Ans: The following are storage classes supported in C++
auto, static, extern, register and mutable.
13. What is the role of mutable storage class specifier?
Ans: A constant class object’s member variable can be altered by declaring it using mutable storage class specifier. Applicable only for non-static and non-constant member variable of the class.
14. Distinguish between shallow copy and deep copy.
Ans: Shallow copy does memory dumping bit-by-bit from one object to another. Deep copy is copy field by field from object to another. Deep copy is achieved using copy constructor and or overloading assignment operator.
15. What is a pure virtual function?
Ans: A virtual function with no function body and assigned with a value zero is called as pure virtual function.
16. What is an abstract class in C++?
Ans: A class with at least one pure virtual function is called as abstract class. We cannot instantiate an abstract class.
17. What is a reference variable in C++?
Ans: A reference variable is an alias name for the existing variable. Which mean both the variable name and reference variable point to the same memory location. Therefore update on the original variable can be achieved using reference variable too.
18. What is role of static keyword on class member variable?
Ans: A static variable does exit though the objects for the respective class are not created. Static member variable share a common memory across all the objects created for the respective class. A static member variable can be referred using the class name itself.
19. Explain the static member function.
Ans: A static member function can be invoked using the class name as it exits before class objects comes into existence. It can access only static members of the class.
20. Name the data type which can be used to store wide characters in C++.
Ans: wchar_t