|
Right, that should do it.
|
|
|
|
|
Doh.
Apparently you can't set properties in nested structs... the following is not allowed:
my Class
{
myStructInner
{
public int myInt { get; set; }
}
myStructOuter
{
public myStructInner structProp { get; set; }
}
myMethod()
{
myStructOuter thingy = new myStructOuter();
myStructOuter.myStructInner.myInt = 5;
}
}
Compiler claims that you cannot "change the return value from myStructOuter.myStructInner.myInt", as it's not a "variable".
|
|
|
|
|
Because it is a struct, a value type not a reference type. When you write someObject.SomeStruct , you are getting a new copy of the somestruct instance and modifying something on that copy won't reflect on the original one.
To avoid this issue, you should create a new struct instance and assign to the property.
|
|
|
|
|
yeah, that kind of defeats my purpose. I need more resolution than that. I need to be able to hand the top level struct around and let any code in my class modify any individual field therein, no matter how nested.
So I'm left with either
(a) flattening out the entire struct, which I am loathe to do or
(b) writing Set() methods at the top level which are knowledgeable about all of the fields of the nested structs.
I'm leaning towards (b). But I hate it.
|
|
|
|
|
Are there any specific reasons for a choosing struct ? It's hard to make it right. Use classes instead.
|
|
|
|
|
I want to test a "name" field on my form and am using regualr expression. My regular expression doesn't pass all the test cases shown below can you please help me in it. The maximum name field can have is 100 characters.
if (Regex.Match(this.textBox1.Text, "^[a-zA-Z0-9_ ]+(')?([ a-z])?$").Success)
{
MessageBox.Show("valid");
}
else
{
MessageBox.Show("not valid");
}
test cases
code project -->valid
codeproject -->valid
codeproject's -->valid
codeproject's program --->valid
codeproject's and codeproject's -->valid
codeproject's and code project's --->valid
code project's and code project's -->valid
|
|
|
|
|
What is it that you are trying to do, really? This regular expression should work with all your test cases, but I'm pretty sure that's not what you want to do:
^code ?project('s( program| and code ?project's)?)?$
Despite everything, the person most likely to be fooling you next is yourself.
|
|
|
|
|
Hi
I need to build a program which do the following:
1. Convert the sound output(amplitude) from the sound card in to floating point numbers ranging from 0.0f to 1.0f.
2. Additional requirements:
a) The audio can be split up in to 4 different frequency ranges:
ie one floating point number for the amplitude of frequency range 0kHz to 4KHz for voice
one floating point number for 4Khz to 8KHz
one floating point number for 8Khz to 15Khz
and last one for 15 to 24Khz
Basically, what I would need is a function which can recognize the frequency and amplitude, like ones frequently used for creating visualizations for media players.
If anyone have such a readymade code, please send to me at deepakpaul_john@infosys.com and also at deepakpaul13@yahoo.com or post in the forum.
Please note that I am very new to C# and be as elaborate as possible while giving your suggestions.
Thank you
|
|
|
|
|
If you want code writing try paying for it - a site like rentacoder.com should be able to help.
Bob
Ashfield Consultants Ltd
|
|
|
|
|
But I dont think I have enough resources to engage professionals. I have seen some people posting some code which can actually process audio, like FFT and all. But the problem is its gonna take time to understand that. So if some one can tell me what to do or what to use, that would be helpful.
|
|
|
|
|
Deepak Paul John wrote: I have seen some people posting some code which can actually process audio, like FFT and all
Good start.
Deepak Paul John wrote: But the problem is its gonna take time to understand that
And thats a problem for you.
It sounds like another college assignment running late. Shame.
Bob
Ashfield Consultants Ltd
|
|
|
|
|
. Hehe. Actually I am a developer working on mainframe paltform.
And the requirement is programming a Microsoft Xbox 360 Contoller. Most of the games does not support force feedback. So I want to enable that. The force feedback part is done but the audio part is still left behind. Due to my very lack of knowledge of C#, am stuck. My expertise is in COBOL, IMS, REXX and ISPF Dialogue Programming. I take up VB both .NET and Office, as hobby and create tools to ease things in my life and work environment. Now the VC# has got me spread out pretty thin. So now you have got a back ground, can you help me out with something?
|
|
|
|
|
Deepak Paul John wrote: Actually I am a developer working on mainframe paltform
Sorry, but it did sound like a piece of college work. Unfortunatley I don't know much about converting audio so I can't be of help - perhaps a Google would reveal something?
Bob
Ashfield Consultants Ltd
|
|
|
|
|
Hm....I have been trying that. I ahve got lots of source code from Code Project. But as I said, it will take time. I am going through them, but I can't put much time in to this since I have other high priority tasks. So I am waiting for some one to help me out, at the same time trying to make something out of the sources I got from code project.
|
|
|
|
|
No easy answers for you - but the code in this article[^] shouldn't be too hard to use as a base for what you want.
DaveBTW, in software, hope and pray is not a viable strategy. (Luc Pattyn)Expect everything to be hard and then enjoy the things that come easy. (code-frog)
|
|
|
|
|
Thanks Dave. I have got a start now. I was able to do some work on the code and get my results. But there is a hurdle. In the application, to which you have given me the link, the source is from an audio file. But I want to take a feed from the sound card/audio out. Can you give some suggestions?
Thank you
|
|
|
|
|
I see that you're in touch with the article's author - he's far more qualified to help than I am so I'll leave it between you.
If you get it sorted - please post back with the solution as I'd be interested as well.
DaveBTW, in software, hope and pray is not a viable strategy. (Luc Pattyn)Expect everything to be hard and then enjoy the things that come easy. (code-frog)
|
|
|
|
|
Guys,
Have a look at next MSDN[^]article.
It says that if you have a combobox cell, you need to remove and re-add the eventhandler for that combobox.
this looks pretty stupid and error prone:
- Can't you set the eventhandler for each row once when loading the grid?
- I believe that in .Net 1.1 you could create your own class that contained a control (fully manageable) ? (We're working with 2.0)
Is there a better way to have control over a combobox in a datagridview?
thanks.
|
|
|
|
|
Hi
how do i write files to a database, i have used streams in vb before, but i cant see an example of doing it in c#. can anyone please help me with a simple example or links to examples.
in the table the column format is image
thank u
|
|
|
|
|
what kind of database do you use?
|
|
|
|
|
|
i try doing the following
streamreader strReader = new StreamReader(@"c\logfile.pdf")
;
and then i pass it as parameter like this
SqlCmd.Parameters.AddWithValue("@Attachment", strReader.ReadToEnd());
But i get the following error message
System.Data.SqlClient.SqlException: Operand type clash: nvarchar(max) is incompatible with image
|
|
|
|
|
you want to use varbinary(max) instead.
|
|
|
|
|
will this handle any file format Leppie
|
|
|
|
|
omlac wrote: will this handle any file format
Yes, as long as you pass a byte[] into it (I see your snippet was reading a string, you probably want the bytes instead).
|
|
|
|