|
well in both cases you should know what return type to expect so...
var orderByDate = from dr in dsR.Tables["MyTable"].AsEnumerable()
Where (int)dr["ReportID"] == 3
select dr;
and...
var orderByDate = from dr in dsR.Tables["MyTable"].AsEnumerable()
Where (string)dr["ReportName"] == "Carl"
select dr;
or ToString() them both and compare them as strings...
var orderByDate = from dr in dsR.Tables["MyTable"].AsEnumerable()
Where dr["ReportID"].ToString() == "3"
select dr
and...
var orderByDate = from dr in dsR.Tables["MyTable"].AsEnumerable()
Where dr["ReportName"].ToString() == "Carl"
select dr;
Life goes very fast. Tomorrow, today is already yesterday.
|
|
|
|
|
sanke_s wrote: if(p_type == "String") return Convert.String(p_value);
You do not need to use convert here since, p_value is already a string.
1. You can use return type as object. The only thing is that you will have to cast the return value.
2. You can also go for overloading.
3. If convert is the only task, why do you even need this method?
जय हिंद
|
|
|
|
|
Well, you could accomplish this using generics. Here's one way:
private T CastTo<T>(string value)
{
if (typeof(T) == typeof(int))
{
int output = 0;
int.TryParse(value.ToString(), out output);
return output;
}
} Obviously, this isn't perfect because you have to add a load of these cases - but it is doable. You would call is using:
.Where CastTo<int>("44") == 44
"WPF has many lovers. It's a veritable porn star!" - Josh Smith As Braveheart once said, "You can take our freedom but you'll never take our Hobnobs!" - Martin Hughes.
My blog | My articles | MoXAML PowerToys | Onyx
|
|
|
|
|
this is the problem,
how to send in the right type.
the type is stored in string variable.
.Where CastTo<int>("44") == 44
it would look something like this.
string type="int";
.Where CastTo< type >("44") == 44
|
|
|
|
|
No, I don't think you can. You can return an object of course and do your thing with that afterwards.
You can return a generic T, but without generic type constraints you might be limited to what you can actually do in your method.
static T TMethod<T>(T value)
{
return value;
}
DaveBTW, in software, hope and pray is not a viable strategy. (Luc Pattyn) Visual Basic is not used by normal people so we're not covering it here. (Uncyclopedia) Why are you using VB6? Do you hate yourself? (Christian Graus)
|
|
|
|
|
private object castTo(string typeName, object value)
{
Type castingType = Type.GetType(typeName);
return Convert.ChangeType(value, castingType);
}
That doesn't use generics, and it isn't type safe, but it does have the same method signature and have almost identical behaviour (I think you'll need to fully specify the type name though)
For a generic version, try this:
private T castTo<T>(object value)
{
Type castingType = typeof(T);
return (T)Convert.ChangeType(value, castingType);
}
It's type safe and far better-looking. One niggle though - the converted type must implement IConvertible
|
|
|
|
|
How to find Internet Explorer target folder, i.e., the IE installation folder in a System through c# code?
I want inject a dll in IE installation folder, In c# How can I do this through a MSI setup?
|
|
|
|
|
well Internet Explorer puts itself in the program files, and as far as I know it is always in 'Internet Explorer' so maybe the following will work for you...
string IEFolderPath = Environment.GetFolderPath(Environment.SpecialFolder.ProgramFiles) + "\\Internet Explorer\\";
Of Course, I don't know this for sure, I suppose you could look in the system registry settings and see if the installation folder is stored in there somewhere
Life goes very fast. Tomorrow, today is already yesterday.
|
|
|
|
|
my code:
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
namespace Din_Checkers
{
class Board
{
public const int x_bounds = 8;
public const int y_bounds = 8;
public PictureBox[,] checkers_board { get; set; }
public Label score = new Label();
public ImageList imageList1 = new ImageList();
public int goldEaten = 0;
public int silverEaten = 0;
public int x = 0;
public int y = 0;
public void Board()
{
checkers_board = new PictureBox[x_bounds, y_bounds];
imageList1.Images.Add(Image.FromFile("Images\\silver.jpg"));
imageList1.Images.Add(Image.FromFile("Images\\gold.jpg"));
Image loadGold = imageList1.Images[0];
Image loadSilver = imageList1.Images[1];
for (int i = 0; i < checkers_board.GetLength(0); i++)
{
for (int j = 0; j < checkers_board.GetLength(1); j++)
{
checkers_board[i, j] = new PictureBox();
if (i < 3)
{
if ((i % 2 == 0 && j % 2 == 0) || (i % 2 == 1 && j % 2 == 1))
{
checkers_board[i, j].BackgroundImage = loadGold;
}
}
else if (i > 4)
{
if (((i + j) % 2 == 0) || (i % 2 == 1 && j % 2 == 1))
{
checkers_board[i, j].BackgroundImage = loadSilver;
}
}
checkers_board[i, j].BorderStyle = BorderStyle.Fixed3D;
if ((i % 2 == 0 && j % 2 == 0) || (i % 2 == 1 && j % 2 == 1))
{
checkers_board[i, j].BackColor = Color.White;
}
if (checkers_board[i, j].BackColor != Color.White)
{
checkers_board[i, j].BackColor = Color.Black;
}
checkers_board[i, j].Top = 30 + 55 * i;
checkers_board[i, j].Width = 61;
checkers_board[i, j].Height = 53;
checkers_board[i, j].Left = 30 + 65 * j;
}
}
score.Top = 510;
score.Left = 250;
score.Width = 500;
for (int i = 0; i < checkers_board.GetLength(0); i++)
{
for (int j = 0; j < checkers_board.GetLength(1); j++)
{
checkers_board[i, j].Click += new EventHandler(ChooseEvent_Click);
}
}
}
public void DrawScore()
{
score.Text = "תוצאה: זהובים אכולים- " + goldEaten.ToString() + " כסופים אכולים- " + silverEaten.ToString();
}
public void ChooseEvent_Click(object sender, EventArgs e)
{
string eventChoose = "";
for (int i = 0; i < checkers_board.GetLength(0); i++)
{
for (int j = 0; j < checkers_board.GetLength(1); j++)
{
if (eventChoose == "")
{
if (checkers_board[i, j].BackColor == Color.White)
{
eventChoose = "Handle_Board";
}
}
if (checkers_board[i, j].BackColor == Color.Green)
{
eventChoose = "move";
}
}
}
if (eventChoose == "move")
{
MoveChecker_Click(sender, e);
}
else
{
HandleBoard_Click(sender, e);
}
}
public void HandleBoard_Click(object sender, EventArgs e)
{
for (int i = 0; i < checkers_board.GetLength(0); i++)
{
for (int j = 0; j < checkers_board.GetLength(1); j++)
{
if ((i % 2 == 0 && j % 2 == 0) || (i % 2 == 1 && j % 2 == 1))
{
checkers_board[i, j].BackColor = Color.White;
}
if (checkers_board[i, j].BackColor != Color.White)
{
checkers_board[i, j].BackColor = Color.Black;
}
}
}
for (int i = 0; i < checkers_board.GetLength(0); i++)
{
for (int j = 0; j < checkers_board.GetLength(1); j++)
{
if (checkers_board[i, j] == ((PictureBox)sender))
{
x = i;
y = j;
}
}
}
score.Text = x.ToString() + " " + y.ToString() + "fun0";
int start_x = x - 1, start_y = y - 1, end_x = x + 1, end_y = y + 1;
if (start_x < 0)
{
start_x = 0;
}
if (start_y < 0)
{
start_y = 0;
}
if (end_x > checkers_board.GetLength(0) - 1)
{
end_x = checkers_board.GetLength(0) - 1;
}
if (end_y > checkers_board.GetLength(1) - 1)
{
end_y = checkers_board.GetLength(1) - 1;
}
for (int i = start_x; i <= end_x; i++)
{
for (int j = start_y; j <= end_y; j++)
{
}
}
}
public void MoveChecker_Click(object sender, EventArgs e)
{
for (int i = 0; i < checkers_board.GetLength(0); i++)
{
for (int j = 0; j < checkers_board.GetLength(1); j++)
{
if (checkers_board[i, j] == ((PictureBox)sender))
{
x = i;
y = j;
}
}
}
score.Text = x.ToString() + " " + y.ToString() + "func";
checkers_board[x, y].BackColor = Color.White;
checkers_board[x + 1, y - 1].BackColor = Color.White;
checkers_board[x - 1, y - 1].BackgroundImage = null;
checkers_board[x, y].BackgroundImage = Image.FromFile("Images\\silver.jpg");
for (int i = 0; i < checkers_board.GetLength(0); i++)
{
for (int j = 0; j < checkers_board.GetLength(1); j++)
{
if (checkers_board[i, j].BackColor == Color.Green)
{
checkers_board[i, j].BackColor = Color.White;
}
}
}
}
public static void EatChecker()
{
}
}
}
it says the message in the title and it marks the constactur name what should i do?
|
|
|
|
|
constructors don't have a return type. Get rid of the 'void'
Life goes very fast. Tomorrow, today is already yesterday.
|
|
|
|
|
I want to automate my mobile (Samsung SGH-X660)connected to my PC by a data cable. I want to get the sms to my PC that my mobile receive. How it is possible?
|
|
|
|
|
|
Thank you vary much for your help.
I am trying to read sms from the mobile. The content is in hex format (It may be in PDU fromat) How can I get original message.
I have used following AT commands
1: "AT"
2: "AT+CMGF=0" // 1 for text mode but it doesn't work
3: "AT+CSCS=\"8859-1\"
4: "AT+CPMS=\"SM\""
5: "AT+CMGL=4"
|
|
|
|
|
Try doing some research, this came up on Google [^] but it was mixed in with a load of junk.
Never underestimate the power of human stupidity
RAH
|
|
|
|
|
i have a Menu bar . and i want to create sub item and add it into Menu ... please give me some guide line..
|
|
|
|
|
Assuming the name of your menu is MenuStrip1, then create a new ToolStripMenuItem and add it to the DropDownItems collection of MenuStrip1
|
|
|
|
|
|
xingselex wrote: may u give me as code?
He practically did just give you it as code. If you cant work out the code from what he said then you are way out of your league with what you are trying to do. You need to get a book on the basics of .Net, possible even programming in general if all you do is copy and paste code.
Life goes very fast. Tomorrow, today is already yesterday.
|
|
|
|
|
MenuItem m = new MenuItem("aaa", "1");
Menu1.Items.Add(m);
m.ChildItems.Add(new MenuItem("bbb", "2"));
m.ChildItems.Add(new MenuItem("ccc", "3"));
Padmanabhan
|
|
|
|
|
Hi,
could anyone help me how to send sms using windows application c#
how to make that
Thanks & Regards
Nath
|
|
|
|
|
Some firms run web services which you interface with and use to send the text
You can usually plug a phone into the serial port and manually send the data using it's antenna
You could send an email to the phone and hope that it gets delivered as a text message
|
|
|
|
|
i have to send sms using windows application. If there is anything please
let me know
|
|
|
|
|
I already have. Those are the three main approaches to sending an SMS. Windows application, WPF or console application - they will (almost) all use one of those three approaches. You simply have to investigate which of those would be most practical to you, and research it
|
|
|
|
|
hai
please visit www.rinoshsasidharan.wordpress.com
to see the solution
regards
Rinosh.K.Sasidharan
|
|
|
|
|
Hi,
i am trying to get cursor position clicking anywhere except my application. I used keydown event on my form for checking, it works. But when i click anywhere it does'nt work
please check my code and tell me where am I doing mistak?
Thank you in Advance
(Riaz)
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
namespace MM1
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
Click += new System.EventHandler(Raised_Click);
}
private void Raised_Click(object sender, EventArgs e)
{
label1.Text = Cursor.Position.X.ToString() + " ; " + Cursor.Position.Y.ToString();
}
private void Form1_KeyDown(object sender, KeyEventArgs e)
{
if (e.KeyCode == Keys.Space)
{
label1.Text = Cursor.Position.X.ToString() + " ; " + Cursor.Position.Y.ToString();
}
}
}
}
modified on Friday, May 22, 2009 2:27 AM
|
|
|
|