Dynamic Language Runtime.
Search This Blog
Friday, December 5, 2014
Dynamic Object Runtime C# Example
C# > Sytem.Dynamic > DynamicObject
DynamicObject specifies dynamic behavior at run time.
Example:
Create dynamic object in runtime.
DynamicObject specifies dynamic behavior at run time.
Example:
Create dynamic object in runtime.
Dynamically Add C# Properties at Runtime.
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Dynamic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
namespace WindowsFormsApplication26
{
public class MyDynamicObject : DynamicObject
{
Dictionary<string, object> dictionary = new Dictionary<string, object>();
public object this[string propertyName]
{
get
{
return dictionary[propertyName];
}
set
{
dictionary[propertyName] = value;
}
}
public override bool TryGetMember(
GetMemberBinder binder, out object result)
{
return dictionary.TryGetValue(binder.Name, out result);
}
public override bool TrySetMember(
SetMemberBinder binder, object value)
{
dictionary[binder.Name] = value;
return true;
}
public override bool TrySetIndex(
SetIndexBinder binder, object[] indexes, object value)
{
int index = (int)indexes[0];
if (dictionary.ContainsKey("Property" + index))
dictionary["Property" + index] = value;
else
dictionary.Add("Property" + index, value);
return true;
}
}
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void Form1_Load(object sender, EventArgs e)
{
dynamic obj = new MyDynamicObject();
obj["column1"] = 1;
obj.column2 = 2;
var v1 = obj["column1"];
var v2 = obj.column2;
}
}
}
Etichete:
c#
Wednesday, November 19, 2014
Telerik RadTimePicker Get Selected Time
Telerik > RadTimePicker > Get Time
DateTime dt = radTimePicker.SelectedDate.Value;
string time = dt.ToString("HH:mm:ss");
Get selected time from RadTimePicker c#.
DateTime dt = radTimePicker.SelectedDate.Value;
string time = dt.ToString("HH:mm:ss");
Etichete:
Telerik
Monday, November 17, 2014
Call one constructor from another c#
C > Keywords > This > Call one constructor from another
public Constructor1()
{
}
public Constructor2(string writer) : this()
{
}
Etichete:
c#
Thursday, November 6, 2014
Lambda Expressions in a Query C#
C# > Operators > Lambda > Query
We use lambda expressions in method calls not directly in query syntax.
Simple Example
int[] wages = { 1000, 1200, 1500, 1800, 2000, 2500 };
int highWagesCount = wages.Where(n => n >= 2000).Count();
We use lambda expressions in method calls not directly in query syntax.
Simple Example
int[] wages = { 1000, 1200, 1500, 1800, 2000, 2500 };
int highWagesCount = wages.Where(n => n >= 2000).Count();
Etichete:
c#
Wednesday, November 5, 2014
DataGridView Windows Forms Control
Windows Forms > DataGridView Control
You can use a DataGridView control to display data with or without an underlying data source.
DataGridView contains cells, rows, columns, and borders.
Without specifying a data source, you can create columns and rows that contain data and add them directly to the DataGridView using the Rows and Columns properties.
You can use a DataGridView control to display data with or without an underlying data source.
DataGridView contains cells, rows, columns, and borders.
Without specifying a data source, you can create columns and rows that contain data and add them directly to the DataGridView using the Rows and Columns properties.
Etichete:
Windows Forms
HyperLink ASP.NET Example
ASP.NET > System.Web > Web Controls > HyperLink
Displays a link to another Web page.
Events
Example
<asp:HyperLink ID="HyperLink1" runat="server" NavigateUrl="~/WebForm1.aspx">HyperLink</asp:HyperLink>
Displays a link to another Web page.
Events
Example
<asp:HyperLink ID="HyperLink1" runat="server" NavigateUrl="~/WebForm1.aspx">HyperLink</asp:HyperLink>
Etichete:
asp.net
Subscribe to:
Posts (Atom)