Thursday, 16 June 2016
Tuesday, 25 November 2014
sharepoint help
http://go4answers.webhost4life.com/Example/auto-populating-sharepoint-list-columns-129616.aspx
Thursday, 6 November 2014
query to get the count of Male, count of female in a given city
Que : A table has following layout ; CITY, NAME , SEXHow do you write a query to get the count of Male, count of female in a given city XXX.Query result should be in a single row with count of male , count of female as columns?
Ans :-
-------------------------------------------------
SELECT CITY, COUNT(MALE), COUNT(FEMALE)
FROM
( SELECT CITY,
case WHEN SEX='M' THEN 'M' ELSE NULL END MALE,
case WHEN SEX='F' THEN 'F' ELSE NULL END FEMALE
FROM TAB_PT
)
GROUP BY CITY
------------------------------------or-------------------------------------------------
select city,(count(case when gender = 'Male' then 1 else 0 end)) 'male',
(count(case when gender = 'Female' then 1 else 0 end)) 'female'
from table
where city = 'give the city'
FROM
( SELECT CITY,
case WHEN SEX='M' THEN 'M' ELSE NULL END MALE,
case WHEN SEX='F' THEN 'F' ELSE NULL END FEMALE
FROM TAB_PT
)
GROUP BY CITY
------------------------------------or-------------------------------------------------
select city,(count(case when gender = 'Male' then 1 else 0 end)) 'male',
(count(case when gender = 'Female' then 1 else 0 end)) 'female'
from table
where city = 'give the city'
Wednesday, 5 November 2014
WPF Questions and Answers
Que 1: - What is WPF and how it is better than Winforms?
Que 2 :- How to implement threading in WPF?
Que 3: - Explain one way, two way, one time & one way to source bindings?
Que 4 :- Explain UpdateSourceTrigger in WPF ?
Que 5 :- Explain WPF Resources ?
Que 6 :- What are WPF Value Converters ?
Que 7 :- Explain WPF multibindings and multivalueconverters ?
Que 8:- Explain logical tree, visual tree,routed events?
Que 9 :- What are WPF commands and INotifyPropertyChange interface ?
Que 10 :- Explain MVVM with a demonstration ?
Que 11 :- What are WPF styles and triggers ?
Que 12 :- What are various ways of doing alignment in WPF ?
Que 13 :- Differentiate between data templates and Control templates ?
Que 14 :- How are WPF observable collection different from .NET collections ?
Que 15:- Explain WPF object hierarchy?
Sunday, 7 September 2014
constructors & Destructors order
Creating A
Creating B
Creating C
Object Created
Press enter to Destroy it
Destroying C
Destroying B
Destroying A
------------------------------------------
using System;
class A
{
public A()
{
Console.WriteLine("Creating A");
}
~A()
{
Console.WriteLine("Destroying A");
}
}
class B:A
{
public B()
{
Console.WriteLine("Creating B");
}
~B()
{
Console.WriteLine("Destroying B");
}
}
class C:B
{
public C()
{
Console.WriteLine("Creating C");
}
~C()
{
Console.WriteLine("Destroying C");
}
}
class App
{
public static void Main()
{
C c=new C();
Console.WriteLine("Object Created ");
Console.WriteLine("Press enter to Destroy it");
Console.ReadLine();
c=null;
//GC.Collect();
Console.Read();
}
}
Saturday, 7 December 2013
Wednesday, 30 October 2013
Tuesday, 27 August 2013
Difference between Dictionary and Hashtable
Simply,
Dictionary<TKey,TValue> is a generic type, allowing:- static typing (and compile-time verification)
- use without boxing
If you are .NET 2.0 or above, you should prefer
Dictionary<TKey,TValue> (and the other generic collections)
A subtle but important difference is that
Hashtable supports multiple reader threads with a single writer thread, while Dictionary offers no thread safety. If you need thread safety with a generic dictionary, you must implement your own synchronization or (in .NET 4.0) useConcurrentDictionary<TKey, TValue>.Wednesday, 21 August 2013
What Is the Difference between Synchronous and Asynchronous?
Answer
The difference between Asynchronous and Synchronous is that Synchronous is the more efficient method of PC communication. However Asynchronous is the most
common method of communication used for email applications, internet access and networking. Synchronous is usually used for transmission of large data bocks.
---------------------
Asynchronous communication works much like the postal system: An application creates a message (that's a piece of data such as the text String "Order 1000 barrels
crude oil", or an XML expression), and labels the message with a destination address (that's typically the logical name of a "mail box", and not an IP address).
The message is passed to the messaging middleware system.
Now the sender application proceeds happily, without needing to wait for the message to be delivered.
Synchronous communication works much like a phone call. The Receiver (callee) must be available, otherwise the conversation cannot occur.
There are many pros and cons about both models, and many details (message priorities, message persistency, forwarding and routing, etc.).
------------------------------
Answer
The difference between Asynchronous and Synchronous is that Synchronous is the more efficient method of PC communication. However Asynchronous is the most
common method of communication used for email applications, internet access and networking. Synchronous is usually used for transmission of large data bocks.
---------------------
Asynchronous communication works much like the postal system: An application creates a message (that's a piece of data such as the text String "Order 1000 barrels
crude oil", or an XML expression), and labels the message with a destination address (that's typically the logical name of a "mail box", and not an IP address).
The message is passed to the messaging middleware system.
Now the sender application proceeds happily, without needing to wait for the message to be delivered.
Synchronous communication works much like a phone call. The Receiver (callee) must be available, otherwise the conversation cannot occur.
There are many pros and cons about both models, and many details (message priorities, message persistency, forwarding and routing, etc.).
------------------------------
Advantages and disadvantages
| Advantages | Disadvantages | |
|---|---|---|
| Asynchronous transmission |
|
|
| Synchronous transmission |
|
|
Friday, 16 August 2013
Gradient button
Gradient button c#
add this class in your form.cs
Download Code
public class rakeshButton : System.Windows.Forms.Button
{
// declare two color for linear gradient
private Color cLeft;
private Color cRight;
// property of begin color in linear gradient
public Color BeginColor
{
get
{
return cLeft;
}
set
{
cLeft = value;
}
}
// property of end color in linear gradient
public Color EndColor
{
get
{
return cRight;
}
set
{
cRight = value;
}
}
public rakeshButton()
{
// Default get system color
cLeft = SystemColors.ActiveCaption;
cRight = SystemColors.Control;
}
protected override void OnPaint(System.Windows.Forms.PaintEventArgs e)
{
// declare linear gradient brush for fill background of Button
LinearGradientBrush GBrush = new LinearGradientBrush(
new Point(0, 0),
new Point(this.Width, 0), cLeft, cRight);
Rectangle rect = new Rectangle(0, 0, this.Width, this.Height);
// Fill with gradient
e.Graphics.FillRectangle(GBrush, rect);
// draw text on label
SolidBrush drawBrush = new SolidBrush(this.ForeColor);
StringFormat sf = new StringFormat();
// align with center
sf.Alignment = StringAlignment.Center;
// set rectangle bound text
RectangleF rectF = new RectangleF(0, this.Height / 2 - Font.Height / 2, this.Width, this.Height);
// output string
e.Graphics.DrawString(this.Text, this.Font, drawBrush, rectF, sf);
}
}
and declare it
public partial class Form1 : Form
{
private rakeshButton mybutton;
-----------and call this object with class insistilization
public Form1()
{
InitializeComponent();
this.rkbutton = new rakeshButton();
this.rkbutton.BeginColor = System.Drawing.SystemColors.ActiveCaption;
this.rkbutton.EndColor = System.Drawing.SystemColors.Control;
this.rkbutton.Name = "gLabel1";
this.rkbutton.Font = new Font("Verdana", 12F, FontStyle.Bold);
this.rkbutton.Size = new System.Drawing.Size(352, 56);
this.rkbutton.TabIndex = 0;
this.rkbutton.Text = "Test gradient Button";
this.Controls.Add(rkbutton);
}
Thursday, 15 August 2013
Blending
http://www.codeproject.com/Articles/20018/Gradients-made-easy
Blending
With blending, we can define a custom gradient and therefore take control over how the gradient is rendered. Blending allows us to override the normal blending behavior and set points along the path where we define alternate drop off rates. We still go from a start color to an end color, but as you can see in the figure below, the drop off rates at the various positions allow much greater control over the rendering process.
Figure 6. Blending using LinearGradientBrush (left) and PathGradientBrush (right)
A couple of terms are in order here:
- Position - A point along the gradient path
- Factor - Drop off rate at the defined position
In Figure 6 above, I have numbered the positions, and combined with the listing below, you will get a better understanding of how blending works. This code is used to produce the right hand drawing in Figure 6.
private void label1_Paint(object sender, PaintEventArgs e)
{
GraphicsPath gp = new GraphicsPath();
gp.AddEllipse(label1.ClientRectangle);
PathGradientBrush pgb = new PathGradientBrush(gp);
pgb.FocusScales = new PointF(0f, 0f);
Blend blnd = new Blend();
blnd.Positions = new float[] { 0f, .25f, .5f, .75f, 1f };
blnd.Factors = new float[] { 1f, 0f, 1f, 0f, 1f };
pgb.Blend = blnd;
e.Graphics.FillPath(pgb, gp);
pgb.Dispose();
gp.Dispose();
}
Both gradients were drawn using the same values, and from what we've learned so far, the outcome is predictable. The only difference being the
PathGradientBrush, the positions radiate outward from the center point, and at the positions noted, you can see the transitions made.
Note: There are three things that are very important here:
- The number of positions and factors must be the same.
- The first position must be 0 and the last 1.
- The number of positions, factors, and colors should not exceed the number of points in the graphics point list. If it does, I turn off color blending, or GDI+ throws an exception. (Working on this.)
If either of these conditions is not met, GDI+ will throw an exception.
SocketHelper class will help you to socket Programming
SocketHelper
using System;
using System.Collections.Generic;
using System.Text;
using System.Windows;
using System.Windows.Forms;
using System.Runtime.CompilerServices;
namespace TestIt.helper
{
public static class SocketHelper
{
public static byte[] GetByteArrayFromStructure(byte[] CompleteStructure, int StartPosition, int length)
{
byte[] temp = new byte[length];
for (int ArrayCount = 0; ArrayCount < length; ArrayCount++)
{
temp[ArrayCount] = CompleteStructure[StartPosition + ArrayCount];
}
return temp;
}
public static char[] GetPreciseArrayForString(string Str, int ArraySize)
{
Str = Str.Replace('\0', ' ');
string temp = new string(' ', ArraySize);
temp = Str + temp;
temp = temp.Substring(0, ArraySize);
temp = temp.Replace(' ', '\0');
return temp.ToCharArray();
}
public static byte[] ConvertCharFrom16to8bit1(char[] CharArray)
{
byte[] temp = Encoding.ASCII.GetBytes(CharArray);
return temp;
}
public static byte[] GetBytesFromNumbers1(Int16 Number)
{
byte[] temp = BitConverter.GetBytes(Number);
return temp;
}
public static byte[] GetBytesFromNumbers1(Int32 Number)
{
byte[] temp = BitConverter.GetBytes(Number);
return temp;
}
public static T[] SubArray<T>(this T[] data, int index, int length)
{
T[] result = new T[length];
Array.Copy(data, index, result, 0, length);
return result;
}
public static string ByteString(this byte[] data)
{
string Message = Encoding.UTF8.GetString(data, 0, data.Length);
return Message.Replace('\0', ' ').Trim();
}
}
}
Subscribe to:
Posts (Atom)