|
thank for the link will go read into it^^.
my main probleme is my MainServer is on a pc that have not yet a fixed IP.
so i need to tell public application what is my Mainserver IP since it change when i restart server.
here is the issue i have to get public comunicate with a "well known site" where they got my PC IP.
then it mean ether autorise read it in the database or DL at a IP.XML file (haker can deturn then the whole traffic to his server seting his ip in database or uploading new xml ).
i think firt i may need a fix IP for my PC so i dont need an other "Rendez vous" but i was waiting install linux before turn my pc into a server.
thank for the link anyway.
|
|
|
|
|
You don't necessarily need a fixed IP address (although it's obviously preferable). If you use a domain name then that will resolve via DNS look ups to a specific IP address. This can be updated dynamicly whenever your IP changes. Google for dynamic DNS.
If someone changes the IP or domain name to a different one, then surely the information that is requested from the server will not be available and just render the application useless until the correct settings are reapplied. I don't quite get the problem here. I can save a link to http://69.10.233.10 and change it in the source to http://74.125.39.147, but then I'm going to get Google instead of CodeProject - not much use if I'm wanting to use what CodeProject has to offer, so my link is now of no use to me.
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)
|
|
|
|
|
|
Hi,
is it possible to have method that returns diffrent datatypes.
this is what i wont todo, used with linq:
.Where castTo("Int32","44") == 44
private ??? castTo(string p_type, string p_value)
{
if(p_type == "Int32") return Convert.Int32(p_value);
if(p_type == "String") return Convert.String(p_value);
}
Thanks
|
|
|
|
|
Nope. Functions can have different return types if there signatures are different, but then they are technically different functions...
private string GetThis(string s)
{
return s;
}
private int GetThis(int i)
{
return i;
}
you could try return an object then just testing the object that you get back from the function to see what type it is and do what you want then.
Anyway you function is basically pointless as you have to specify the type with each call anyway so you so you may as well just to do conversion in code based on what you want to get back.
Life goes very fast. Tomorrow, today is already yesterday.
|
|
|
|
|
Could you please submit an example on how I can use typeof in my LINQ query?
Sometimes the in parameter returns an Int32 and sometimes it returns a String.
var orderByDate = from dr in dsR.Tables["MyTable"].AsEnumerable()
Where MyFunction(dr["ReportID"]) == 3
select dr;
and sometimes
var orderByDate = from dr in dsR.Tables["MyTable"].AsEnumerable()
Where MyFunction(dr["ReportName"]) == "Carl"
select dr;
|
|
|
|
|
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
|
|
|
|