473,387 Members | 3,787 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

Correct syntax in an overloaded method

In ClassA.cs I have this

Expand|Select|Wrap|Line Numbers
  1. public struct tChannel
  2.     {
  3.         [MarshalAsAttribute(UnmanagedType.I1)]
  4.         public bool IsSigned;
  5.         public byte BitSize;
  6.         public sbyte UnitExponent;
  7.         public uint Unit;
  8.         [MarshalAsAttribute(UnmanagedType.ByValTStr, SizeConst = 24)]
  9.         public string UnitStr;
  10.         [MarshalAsAttribute(UnmanagedType.ByValTStr, SizeConst = 24)]
  11.         public string ChannelName;
  12.         [MarshalAsAttribute(UnmanagedType.ByValTStr, SizeConst = 24)]
  13.         public string UserChannelName;
  14.         [MarshalAsAttribute(UnmanagedType.ByValTStr, SizeConst = 24)]
  15.         public string UserChannelName_NV;
  16.         [MarshalAsAttribute(UnmanagedType.ByValArray, SizeConst = 64, ArraySubType = UnmanagedType.I1)]
  17.         public byte[] RFU;
  18.     }
  19.  
  20. public struct tOakSensor
  21.     {
  22.         [MarshalAsAttribute(UnmanagedType.ByValTStr, SizeConst = 256)]
  23.         public string DevicePath;
  24.         public ushort VID;
  25.         public ushort PID;
  26.         public ushort REV;
  27.         [MarshalAsAttribute(UnmanagedType.ByValTStr, SizeConst = 24)]
  28.         public string SN;
  29.         [MarshalAsAttribute(UnmanagedType.ByValArray, SizeConst = 64, ArraySubType = UnmanagedType.I1)]
  30.         public byte[] RFU;
  31.         [MarshalAsAttribute(UnmanagedType.ByValTStr, SizeConst = 24)]
  32.         public string DeviceName;
  33.         [MarshalAsAttribute(UnmanagedType.ByValTStr, SizeConst = 24)]
  34.         public string UserDeviceName;
  35.         [MarshalAsAttribute(UnmanagedType.ByValTStr, SizeConst = 24)]
  36.         public string UserDeviceName_NV;
  37.         public ushort NumChannels;
  38.         [MarshalAsAttribute(UnmanagedType.ByValArray, SizeConst = 11)]
  39.         public tChannel[] Channel; 
  40.  
  41.    }
  42.  
  43.  
  44.  public class OakSensor
  45.  
  46. {
  47.         public static extern bool Oak_FindSensor_a(ushort PID, ushort REV, string SN, string DeviceName, string ChannelName, string UserDeviceName, string UserChannelName, ref tOakSensor SensorFound);
  48. }       
  49.  
I need to use the Oak_FindSensor_a method in another class
So in ClassB.cs I try to use an overloaded method
Expand|Select|Wrap|Line Numbers
  1. private void CmdLancer_Click_1(object sender, EventArgs e)
  2.         {
  3.             tOakSensor sensor = new tOakSensor();
  4.             tChannel sensora = new tChannel();
  5.  
  6.  
  7.             OakSensor.Oak_FindSensor_a(sensor.PID, sensor.REV, sensor.SN, sensor.DeviceName, sensora.ChannelName, sensor.UserDeviceName, sensora.UserChannelName, ref sensor);
  8.  
  9.             textBox3.Text = sensor.SN;
  10.             textBox4.Text = sensor.DeviceName;
  11.             textBox5.Text = sensora.ChannelName;
  12.             textBox6.Text = sensor.UserDeviceName;
  13.             textBox7.Text = sensora.UserChannelName;
  14.         }
  15.  
As you see there is sensor. and sensora. in the method arguments.
The code compile well but does not return the sensora.ChannelName and the sensora.UserChannelName

I guess I have a syntax error. How can I handle that ?
Regards
Apr 25 '11 #1
0 922

Sign in to post your reply or Sign up for a free account.

Similar topics

5
by: Dynamo | last post by:
Hello again ;-) What is the correct syntax to use when inserting a value into a table that contains a variable name with spaces. This works $query = "INSERT INTO Catalogue (Author) VALUES...
2
by: Tim | last post by:
In an ASP web page I am trying to calculate a value in seconds from two date and times. Can anyone help me find the correct syntax to make this work?!?! (This code below work correctly)...
0
by: Alistair | last post by:
hello again people... Access2000, IIS6, win XP pro I have a form where users can enter search criteria for various products. now, if this form has 2 fields, colour and size (it wil have more...
1
by: Oplec | last post by:
Hi, I'm learning C++ as a hobby using The C++ Programming Language : Special Edition by Bjarne Stroustrup. I'm working on chpater 13 exercises that deal with templates. Exercise 13.9 asks for me...
2
by: Saradhi | last post by:
how to create a delegate for a overloaded method? Thanks a Lot -SARADHI
3
by: martinharvey | last post by:
This is probably a very simple question but i would appreciate some help with the correct syntax for and update stored procedure I have created a user form that allows the user to update the...
1
by: Mike P | last post by:
I am building a message body to be sent by email, but I can't seem to get the correct syntax for 2 lines where I am defining the <formand trying to pass parameters and where I am creating a...
5
by: sam | last post by:
Why the folowing code generates ans error in the select expression ?: DataRow drRows = dsRevues.Tables.Select("year >= '2000' && year <= '2007'");// What is the correct syntax ? Sam
3
by: thaytu888888 | last post by:
In the aspx.cs file, i call userService.Insert(userEntity); Codes: UserService userService = new UserService(); User userEntity = new User(); ...
2
by: Andy Champ | last post by:
We have a class with something that, simplified, looks like this: template <typename Tclass foo { T beyondAllReaching; // In VC2005, this works OK template <typename Ufriend void...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.