|
You're using the wrong container to start with. If you want to store name/value pairs, use a dictionary to do it, or create a struct to contain the values. If you used a dictionary, then you could use FNAME and LNAME as keys and look the values up by key.
Christian Graus
Driven to the arms of OSX by Vista.
Read my blog to find out how I've worked around bugs in Microsoft tools and frameworks.
|
|
|
|
|
well I am not a core C# programmer. so dont know much about it as U guys.
I mainly work on Delphi.
Anyways,
I am getting this data back form Web Service in the Format Mentioned.
I can anyways Use String functions to Match and get Values, but just valted to know if there is anything Handy I can use.
In Delphi I can get values just by specifying the lable for the List member. Dont know with C#.
Your help will be appreciated.
Thanks.
Niks
|
|
|
|
|
OK - well, in the first instance, you can use the split method on the string class, so long as there's always one = sign in the string. Otherwise, you can use regex to split it up.
So
string s = "FNAME=fred";
string [] vals = s.Split("=");
vals[0] is now FNAME= and vals[1] is now fred. You could then pass these values into a dictionary for later lookup.
Christian Graus
Driven to the arms of OSX by Vista.
Read my blog to find out how I've worked around bugs in Microsoft tools and frameworks.
|
|
|
|
|
Yeah, that's what I'd probably do.
Or write a class (or struct) that will deserialize from the provided datastream.
|
|
|
|
|
Hi guys
I have this struct in C++.
<br />
struct image<br />
{<br />
x:4;<br />
y:4;<br />
color:8;<br />
grayscale:1;<br />
spare:7;<br />
}<br />
<br />
<br />
what is the equivalent in C#?
|
|
|
|
|
Hi,
AFAIK C# does not support bit fields like C and C++ do.
You could create a struct with the right number of bytes, and give it properties supporting getting and setting the individual fields.
BTW: if you were to use that from multiple threads, you would have to provide a lock!
Luc Pattyn [Forum Guidelines] [My Articles]
The quality and detail of your question reflects on the effectiveness of the help you are likely to get.
Show formatted code inside PRE tags, and give clear symptoms when describing a problem.
|
|
|
|
|
Thank you for your reply.
I have already used byte and ushort variables with left shifting but the problem is I will have more then one variable in a byte or short variable
ex
byte xy = x << 4 + y;
sometimes I will have 3 or more variables in one.I am looking for ideas, what about p-invoke?, I haven't used it before.
|
|
|
|
|
This is part of the solution:
public struct image {
private byte xy;
private byte color;
private byte gray;
public int X {
get { return xy>>4;}
sey { xy=(value<<4) | (xy&0xF);}
}
etc.
}
Luc Pattyn [Forum Guidelines] [My Articles]
The quality and detail of your question reflects on the effectiveness of the help you are likely to get.
Show formatted code inside PRE tags, and give clear symptoms when describing a problem.
modified on Monday, July 20, 2009 8:15 PM
|
|
|
|
|
[Flags]
public enum PizzaToppings
{
ExtraCheese = 1,
Pepperoni = 2,
ItalianSausage = 4,
AmericanSausage = 8,
Peppers = 16,
Mushrooms = 32,
Anchovis = 64,
Pineapples = 128
}
public class Pizza
{
private PizzaToppings toppings;
public PizzaToppings Toppings
{
get{ return toppings; }
set{ toppings = value; }
}
}
Pizza p = new Pizza();
p.Toppings =
PizzaToppings.ExtraCheese |
PizzaToppings.ItalianSausage |
PizzaToppings.Pepperoni;
|
|
|
|
|
pixels are necessarily pizza toppings
Luc Pattyn [Forum Guidelines] [My Articles]
The quality and detail of your question reflects on the effectiveness of the help you are likely to get.
Show formatted code inside PRE tags, and give clear symptoms when describing a problem.
|
|
|
|
|
I thought there was (for interop), using attributes, I just never have so I don't recall.
Maybe I'll investigate a little later.
|
|
|
|
|
All Google could turn up was using field offsets to have several byte variables at the same address, then a lot of SHIFT and AND and OR. But then it doesn't make sense to me to have such unions, why not calculate the aggregate byte right away, as I did in my example.
Luc Pattyn [Forum Guidelines] [My Articles]
The quality and detail of your question reflects on the effectiveness of the help you are likely to get.
Show formatted code inside PRE tags, and give clear symptoms when describing a problem.
|
|
|
|
|
Look into
System.Runtime.InteropServices.StructLayoutAttribute
and
System.Runtime.InteropServices.FieldOffsetAttribute
[StructLayout(LayoutKind.Explicit)]
public class SYSTEM_INFO
{
[FieldOffset(0)] public ulong OemId;
[FieldOffset(4)] public ulong PageSize;
[FieldOffset(16)] public ulong ActiveProcessorMask;
[FieldOffset(20)] public ulong NumberOfProcessors;
[FieldOffset(24)] public ulong ProcessorType;
}
Edit: Oh, wait, that's in bytes, not bits.
|
|
|
|
|
An idea came up to my mind
This is not a working code, it's just for demonstration
<br />
<br />
class image<br />
{<br />
byte x;
byte y;
byte color;
byte grayscale;
byte spare;
<br />
public byte[] getImageByteArray()<br />
{<br />
byte byteArray[3];<br />
byteArray[0] = x<<4 +y;<br />
byteArray[1] = color;<br />
byteArray[2] = grayscale<<7 + spare;<br />
}<br />
}<br />
<br />
I don't know if this will be fine since I am communicating with a real time application, and I have large structs,I mean will this bit manipulation slow the process of sending data over 40ms intervals.
Edit:
Another problem raises when I have fields larger than 8 bits
modified on Tuesday, July 21, 2009 5:02 AM
|
|
|
|
|
You should be able to send data quickly enough. I have an application that does something similar (turns many flags and less than full byte variables into a bit array in 'real time') and it keeps up.
For fields larger than 8 bits, just use the BitConverter class to get a variable of the next size up (eg: ushort for 10 bits, uint for 20 bits) and apply the same masking and combination techniques. Also, I would OR values together instead of adding them.
|
|
|
|
|
|
Hi,
is there a way to split the picturBox on demand, so that only everything underneath the diagonal is usable to paint on it?
|
|
|
|
|
Hell, no. A picturebox is a close to useless control, it's only value is to draw pictures for people too inexperienced to handle their own paint event. If you draw it yourself, you can use an ImageAttributes object in a DrawImage overload of the Graphics class, to specify a color range that would be transparent. This would occur in the Paint event.
Christian Graus
Driven to the arms of OSX by Vista.
Read my blog to find out how I've worked around bugs in Microsoft tools and frameworks.
|
|
|
|
|
Hi Christian,
thanks for your answer. Like i said in the other thread, i unfortunately can't use something else than a picturebox.
Maybe i can draw a graphic(in my case a triangle) in the pb-paint event and set it to be always in the foreground or something like that?!
It's only important that a part of the pb seems to be empty no matter if there was something painted or written.
|
|
|
|
|
Oh, I thought you wanted to disable the bikini on a model.
|
|
|
|
|
hehe good idea but not my intention.
I'm thankfull for any suggestion.
|
|
|
|
|
ok i think i found the solution and yes it is possible
picturebox.setclip should do the work for me. Now im gonna try it...
|
|
|
|
|
Hi,
I have created an Outlook 2007 plugin using VSTO and I am getting an error that I hope someone out there has seen and could help me fix.
The plugin (add-on) is a command bar that simply waits for a (email appointment, or task) property to change (MS CRM stuff - gets changed by Microsofts CRM Integration) and then shows a Windows form asking for a Category. Everything works great unless I follow a very specific set of steps.
What I mean by that is I can get the form to popup a hundred times for Emails, Tasks, and Appointments and never have a problem. Then if I do an appointment a certain way, it blows up and then it will do it for everything until I restart Outlook.
This is the error message I get...
Unable to cast COM object of type 'System.__ComObject' to interface type 'System.Runtime.InteropServices.UCOMIConnectionPointContainer'. This operation failed because the QueryInterface call on the COM component for the interface with IID '{B196B284-BAB4-101A-B69C-00AA00341D07}' failed due to the following error: No such interface supported (Exception from HRESULT: 0x80004002 (E_NOINTERFACE)).
I can find almost no information about UCOMIConnectionPointContainer other then it looks like it is depricated in the .NET Framework 3.5. The odd thing is where this error is occurring, I am not actually trying to cast to a UCOMIConnectionPointerContainer object, I am trying to cast to an Outlook.Appointment object.
Here is the piece of code that causes the error....
if (m_Item is Outlook.AppointmentItem)
{
m_ItemType = OutlookItemType.AppointmentItem;
((Outlook.AppointmentItem)m_Item).CustomPropertyChange += new Microsoft.Office.Interop.Outlook.ItemEvents_10_CustomPropertyChangeEventHandler(Item_PropertyChange);
((Outlook.AppointmentItem)m_Item).Write += new Microsoft.Office.Interop.Outlook.ItemEvents_10_WriteEventHandler(OutlookItem_Write);
}
else if .......
This goes on to check for a Mail Item and a Task Item. Those never fail initially. It is always an Appointment item and once it fails, then I get the error for almost everything.
I hope somebody has seen this an can offer some advice.
Thanks in advance,
Wendell
|
|
|
|
|
Hi,
I am trying to populate data into one grid name Grid1 using the row selected in Grid2. Grid1 and Grid2 have a common ID called ColorID . For a row with ColorID selected in Grid2 I want the data corresposding to that ColorID and also I have few combo boxes in the same grid2 selecting on which data to be populated in Grid1
Can someone help me with this or providing some link from which I might look and try to work on !!
Thanks a lot !!
|
|
|
|
|
I have a Windows form and I want to display a row across the bottom with a group of images.
The image location will be stored in a database.
I want them to be side by side in a single row. I know I can use a datagridview to display them vertically, but I am not sure if this can be done horizontally, nor am I sure if this is the right approach.
What is the right control to use for this? I want to be able to click on each picture and change the current record in the windows form to reflect the selected picture, I want to be able to scroll through the images (Horizontally only).
Is this a job for a repeater or datalist? Does anyone have a URL example of something of this sort?
Thank you in advance.
|
|
|
|