|
sorry:
char com[2]="my text";
string com[2]="my text";
|
|
|
|
|
I suppose you didn't improve yourself enough.
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong.
-- Iain Clarke
[My articles]
|
|
|
|
|
|
an82 wrote: sorry:
char com[2]="my text";
string com[2]="my text";
That's not the problem. I didn't even notice the missing quotation mark.
Both statements are nonsense. It looks like you try to create arrays, but the syntax isn't even close. Look at this:
char[] com1 = new char[3];
com1[0] = 'a';
com1[1] = 'b';
com1[2] = 'c';
string[] com2 = new string[3];
com2[0] = "Hello";
com2[1] = "world";
com2[2] = "!";
And this:
char[] com1 = new char[] { 'a', 'b', 'c' };
string[] com2 = new string[] { "Hello", "world", "!" };
Despite everything, the person most likely to be fooling you next is yourself.
|
|
|
|
|
Nope, they're still nonsense.
"Why don't you tie a kerosene-soaked rag around your ankles so the ants won't climb up and eat your candy ass..." - Dale Earnhardt, 1997 ----- "...the staggering layers of obscenity in your statement make it a work of art on so many levels." - Jason Jystad, 10/26/2001
|
|
|
|
|
an82 wrote: har com[2]="my text;
Your syntax is incorrect but I think I know what you are asking. Here is the correct syntax:
char com[2] = {'A', 'b'};
You are creating an array which has 2 chars in it.
an82 wrote: string com[2]="my text";
string com[2] = {"Correct", "Version"};
Here you are creating an array of strings, not chars. String type is actually an array of chars. This is an "array of chars of array of chars".
When you create a char array you can store characters in them. In a string array you can store strings (one character can also be a string).
Read about arrays, strings, and chars if you are still confused.
|
|
|
|
|
CodingYoshi wrote: Here is the correct syntax:
char com[2] = {'A', 'b'};
That is a bit closer, but it's not correct.
The correct syntax is:
char[] com = new char[] { 'A', 'b' };
Or in C# 3.0 you can use the shorter form:
char[] com = { 'A', 'b' };
Despite everything, the person most likely to be fooling you next is yourself.
|
|
|
|
|
|
If I test this code using static data and bypass the loop this function works ok.
eg
long _item0 = 98855669;
long _item1 = 457788996630; etc
The LIVE data is held in a generic List which is updated during the users session, items are added/removed by the user.
Now when I come to save the selection in the database I need to loop out all the selected items and send them to the SP below.
protected void InsertSeletedProducts(string StrConn)
{
UsersWeb.Cart objCart = (UsersWeb.Cart)Session["Cart"];//Gets the details of the users session including the Products list they selected
long _item0 = 0; //If I add static data here and bypass the loop for testing the function works ok
long _item1 = 0;
long _item2 = 0;
long _item3 = 0;
long _item4 = 0;
foreach (UsersWeb.Products objProducts in objCart.Products) //LOOP/iterate the Generic Products list for all the selected items
{
_item0 = ?; //here I need code to match each UniqueID rows in the list and add them to the Params list for the SP below
_item1 = ?;
_item2 = ?;
_item3 = ?;
_item4 = ?;
}
SqlCommand cmd = new SqlCommand("usp_InsertSelectedItems", new SqlConnection(StrConn));
cmd.CommandType = CommandType.StoredProcedure;
cmd.Parameters.AddWithValue("@item1", _item0);
cmd.Parameters.AddWithValue("@item2", _item1);
cmd.Parameters.AddWithValue("@item3", _item2);
cmd.Parameters.AddWithValue("@item4", _item3);
cmd.Parameters.AddWithValue("@item5", _item4);
cmd.Connection.Open();
cmd.ExecuteNonQuery();
}
Can anyone help??
|
|
|
|
|
|
I found that once I set the interval for the axis, then IntervalAutoMode does not work any longer. (e.g the following code)
this results in one problem for me.
because I want to make sure the minddle value of 0 for axisX to be displayed all the time.
but at the same time, I want to have the variable axisX interval when it is zoomed. it seems above two requiments can not be fulfilled
at the same time. The interval by default is 50, with this interval, the 0 is not displayed for AxisX.
Simply speaking, I want the 0 of axisX is always displayed with ZOOM IN or Zoom out. How to do it? thanks!
chart1.ChartAreas[0].AxisX.Minimum = -160;
chart1.ChartAreas[0].AxisX.Maximum = 160;
chart1.ChartAreas[0].AxisX.Interval = 40;(default 50)
chart1.ChartAreas[0].AxisX.IntervalAutoMode = IntervalAutoMode.VariableCount;
|
|
|
|
|
|
This one will work. You may need to adjust it for your needs:
([^\.]+\.[^\.]+)\.Name\s*=\s*"([^"]+)";
regards
modified 12-Sep-18 21:01pm.
|
|
|
|
|
I'm a little confused about this conversion in C#.
Convert.ToByte('Š') throws an exception as (according to C#) the ordinal value of 'Š' is 352.
I've looked up the 'Š' character in the ASCII chart and the ordinal value is 138.
In Delphi the conversion works fine both ways and it gives me 138 as the ordinal value (just like the ASCII chart).
What am I doing wrong?
|
|
|
|
|
lackonagy wrote: I've looked up the 'Š' character in the ASCII chart and the ordinal value is 138.
On which ASCII chart did you look this up? The real ASCII[^]does not have anything greater than 127 as it is only a 7-bit character set. There are numerous variants of so-called Extended ASCII[^] to represent 8-bit character sets or even more but there is no universal standard and not all of these extended character sets even include the original 128 ASCII characters so it becomes a very slippery slope, as you have just found out.
I'm not sure why Delphi would have returned the ordinal value of 138 for the character 'Š' but I can only assume that it must be because your computer has specific regional settings which uses an extended ASCII character set in which 'Š' translates to 138. To the best of my knowledge the two most popular "extended ASCII" sets are CP437 and CP850, both in which the value 138 translates to 'è' (latin lower case E with grave accent).
In C# the ordinal value of a character is not the ASCII value as you are used to but the character's unicode value. For some more info on converting between character sets you might want to have a look at the Encoding Class[^].
|
|
|
|
|
The unicode value of 'Š' is 352. In C#, we use char to represent the unicode char. So the code as below:
Char s1 = Convert.ToChar("Š");
Hope this will help.
Tan Li
I Love KongFu~
|
|
|
|
|
i want to restrict my application to run only one instance at a time on one machine, is there any option or property which helps, i want to do this when creating a setup for my application.
|
|
|
|
|
|
thanx , i've used mutex before but the problem is how to apply mutex on this application.what should be the critical area?
|
|
|
|
|
|
How can I round a float to an integer?
If I do int i=(int)3.0f it's not good because if 3.0f is like 2.9999999 in memory, I'll get i=2, which is unacceptable. Math.Round only accepts doubles/decimals, which is not an option because I need a float.
Any idea?
|
|
|
|
|
Tony_P wrote: If I do int i=(int)3.0f it's not good because if 3.0f is like 2.9999999
Have you tried it?
Tony_P wrote: Math.Round only accepts doubles/decimals, which is not an option because I need a float
So what? Casting a single to a double is lossless.
I think you're concerned about non-existent problems.
|
|
|
|
|
I wrote a little application to try Remote Events
I have two versions of this application
The first one: both, server and the client are Console application
The first one is working fine
I did not write any methods in Client, just do the Console.Writeline()
The second : server is a console application and the client is winform application. I have problem with second:
The event riesed but this event need to update RichTextBox in my Main form
I get this exception:
Cross-thread operation not valid: Control 'rtb_in' accessed from a thread other than the thread it was created on.
I tryed many approuches nothing helped.
Please help me with this issue.
Here is my code sample
Server:
using REWFComm;
using System.Runtime.Remoting.Channels;
using System.Runtime.Remoting;
using System.Runtime.Remoting.Channels.Tcp;
using System.Runtime.Serialization.Formatters;
using System.Collections;
using System.Reflection;
namespace Server
{
class ServerRemote : MarshalByRefObject, ICommon
{
public void Message(string passed, object Client)
{
Console.WriteLine(passed);
MessageEvent(passed + ": your message is arrived",Client);
}
public event MessageHandler MessageEvent;
}
class Server
{
static void Main(string[] args)
{
Console.WriteLine("Server started\nListening...");
BinaryServerFormatterSinkProvider serverProvider = new BinaryServerFormatterSinkProvider();
serverProvider.TypeFilterLevel = TypeFilterLevel.Full;
IDictionary props = new Hashtable();
props["port"] = 8888;
props["typeFilterLevel"] = TypeFilterLevel.Full;
TcpChannel chan = new TcpChannel(props, null, serverProvider);
ChannelServices.RegisterChannel(chan, false);
RemotingConfiguration.RegisterWellKnownServiceType(typeof(ServerRemote),
"ServerRemote",
WellKnownObjectMode.Singleton);
Console.ReadLine();
}
}
}
Common object:
using System;
using System.Collections.Generic;
using System.Text;
using System.Windows.Forms;
using System.ComponentModel;
namespace REWFComm
{
public delegate void MessageHandler(string myStr, object Sender);
public interface ICommon
{
void Message(string passed, object Sender);
event MessageHandler MessageEvent;
}
public class Messages : MarshalByRefObject
{
public void MessageArrived(string myStr, object Sender)
{
((RichTextBox)Sender).AppendText(myStr); //-- HERE I GET THE EXCEPTION!!!!!
}
}
}
Client:
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using REWFComm;
namespace Client
{
public partial class Main : Form
{
object formobj;
public Main()
{
InitializeComponent();
formobj = this.rtb_in;
}
private void btn_send_Click(object sender, EventArgs e)
{
ICommon obj = (ICommon)Activator.GetObject(typeof(ICommon), "tcp://localhost:8888/ServerRemote");
Messages ms = new Messages();
obj.MessageEvent+=new MessageHandler(ms.MessageArrived);
obj.Message(tb_out.Text,formobj);
}
}
}
modified on Saturday, January 3, 2009 2:13 PM
|
|
|
|
|
Hi,
the methods that get called by the other side are bound to be asynchronous with respect to your main
thread, hence they execute on a different thread; the same is true for most timers, for serial port
receive, etc.
And you are not allowed to touch any Controls (accessing properties, calling methods) from any thread
but the one that created the Control, which normally is the main or GUI thread.
To solve the problem the Control class offers InvokeRequired property and Invoke method.
If you are unfamiliar with them, look them up, there are plenty of examples around.
|
|
|
|
|
Thanks to your replay
I tryed this approuch with Invoke and InvokeRequired
But it doesn't help
Maybe I did not undestand it well
If You can modefy my code you will help me a lot
Thanks
|
|
|
|