Posts

Remove icon from action bar for xamarin forms android project

Put the below code in xamarin.android (xamarin.droid) project. [assembly: ExportRenderer(typeof(NavigationPage), typeof(CustomNavigationRenderer))] namespace Example {     public class RootNavigationRenderer : NavigationRenderer     {         protected override void OnElementChanged(ElementChangedEventArgs e)         {             base.OnElementChanged(e);             RemoveAppIconFromActionBar();         }         void RemoveAppIconFromActionBar()         {             var actionBar = ((Activity)Context).ActionBar;             actionBar.SetIcon(new ColorDrawable(Color.Transparent.ToAndroid()));         }     } }

Difference between var and dynamic in C#

var Introduced in C# 3.0 At compile time, the compiler decide the type of variable which is declared.  Need to initialize at the time of deceleration. Visual Studio shows intellisense as the type of variable assigned is known to the compiler. We cannot assign two data type in one variable since the compiler has already assign the data type to the value.       that is : var obj1=1; obj1="hello";    will through an error. dynamic Introduced in C# 3.0 At runtime time, the compiler decide the type of variable which is declared.  No need to initialize at the time of deceleration. Visual Studio intellisense is not available since the type of variable assigned is unknown to the compiler, which will be known only at the run time. We can assign two data type in one variable since the compiler recreate the type when another data type is assigned to the variable.

Use of Is and As operators in C#

The   is operator checks if an object can be cast to a specific type. if (someObject is StringBuilder) The as operator attempts to cast an object to a specific type, and returns null if it fails. StringBuilder b = someObject as StringBuilder;

Type Casting or Type Conversion Methods

Converting one type of data to another type it is also known as Type Casting.     Type Casting are of two types:           1) Implicit conversion                 int num = 2147483647;                 long bigNum = num;         2) Explicit conversion        double x = 1234.7;                int a;                // Cast double to int.                a = (int)x;

How to Set Multiple Startup Projects in Visual Studio.

To set multiple startup projects In the Solution Explorer , select the solution. Right-click the node to get the context menu. Select Properties . The Solution Property Pages dialog box opens. Expand the Common Properties node, and click Startup Project . Click Multiple Startup Projects and set the appropriatet actions.

NuGet - Check Combo Box

Step 1:  Get the NuGet package https://www.nuget.org/packages/Common.CheckComboBox/ Step 2: Add the CheckComboBox Control in the toolbar. Click here Step 3: Drag the "CheckedComboBox" control from the toolbar to the form to the position where it should be placed   Step 4: Add items to the CheckedComboBox control by        for (int i = 0; i < 10; i++)             {                 checkedComboBox1.Items.Add(i);             }

How to get the list of properties of a class?

public List<string> GetPropertiesNameFromClass(object pObject) { List<string> propertyList = new List<string>(); if (pObject != null) { foreach (var prop in pObject.GetType().GetProperties()) { propertyList.Add(prop.Name); } } return propertyList; } public static Dictionary<string, object> GetPropertDictionaryFromClass(object pObject) { if (pObject == null) return new Dictionary<string, object>(); Type t = pObject.GetType(); PropertyInfo[] props = t.GetProperties(); Dictionary<string, object> dict = new Dictionary<string, object>(); foreach (PropertyInfo prp in props) { object value = prp.GetValue(pObject, new object[] { }); dict.Add(prp.Name, value); } return dic...