|
|
WidmarkRob wrote: So, I don't have to turn this into an executable file before calling it from the command line? Yes you do, that's what building the project is all about.
WidmarkRob wrote: From the command line, I would have to type in "PracticingPassingParameters"?
Then I could just enter my two numbers and get the result? See my anser to your other question.
WidmarkRob wrote: all I really needed was four lines of code in the first place? No, the book is trying to teach you how to write applications, by using different features, even though some of it seems like overkill.
WidmarkRob wrote: even when I publish this simple little program and click on the executable, it still telling me I have an out of range exception You need to show us exactly what you have typed at the command line.
Use the best guess
|
|
|
|
|
Richard MacCutchan wrote: You need to show us exactly what you have typed at the command line.
my blue-collar mind is starting to get a little better, like an idiot… When I published and created a regular executable file, I went and clicked on the executable instead of calling it from the commandline…
When I called up from the commandline, it works just like it was supposed to…
|
|
|
|
|
WidmarkRob wrote: my blue-collar mind Please don't make the mistake of believing that we are all geniuses. Some (Pete O'Hanlon, Sacha Barber, OriginalGriff, and others) definitely are, but most of us are just slightly ahead of you in experience. That is to say, we already made these mistakes and learned how to fix them.
Use the best guess
|
|
|
|
|
I fingered it out, was a pain in the butt… Had to enter the full file path name all the way to the bin folder.
Okay, now that I figured that part out… How do I turn this into an executable file and have it run the same way as I did calling it in the bin folder from the command line?
|
|
|
|
|
WidmarkRob wrote: How do I turn this into an executable file It's already an executable; that's the only type that you can run (yes I know about the exceptions). You open a command window, navigate to the application's bin/Debug or bin/Release directory, and enter the executable's name followed by the relevant parameters, something like:
>cd "\My Documents\Visual Studio\Projects\mytest\bin\Debug"
>testprogram 23 5
When you debug your code, the debugger runs the executable program within a special environment that allows it to single step, and track variable values.
Use the best guess
|
|
|
|
|
I am using your drivedetector(Using Dolinay) to detect usb devices connected to PC. but I want to detect all the devices connected to my PC so that I can transfer data to my form in C#. what Can I do?
C# user
|
|
|
|
|
If you've got questions about a particular article, do to the forum at the bottom of that article.
This site is run by an entire community, volunteering their time, not a couple of people writing thousands of articles. The best person to ask about an article is the person who wrote it.
|
|
|
|
|
I am looking for a C# wrapper to make calls with Skype. I found 3 'Skype' related articles here on CP, and spent an hour Googling, but I can' seem to find a decent example of plaching a call with Skype.
My app will have the skype Id. When the icon is clicked, I want it to call using skype. How hard can this be??
Anyone have an example of this?
If it's not broken, fix it until it is
|
|
|
|
|
|
Have you looked at it?
If it's not broken, fix it until it is
|
|
|
|
|
Briefly, they have an ActiveX control that you can use to issue commands to the Skype system, or if you find one of the wrappers you may be able to roll your own. Tracer looks like it can help you understand the API calls and what is supported, so combining the two and a lot of trial and error it looks like you can interact with Skype via C#.
|
|
|
|
|
Yss I looked at these earlier, but I really didn't want to reinvent something if someone else already has done it.
Ya, Tracer looks promising. Guiess I'll start there.
Thanks
If it's not broken, fix it until it is
|
|
|
|
|
I have the following interfaces, they must inherit in that order, the problem is that i can't make IVideoPlayer to return IVideo as Media. Is this not possible or am I missing something? I'd prefer not to have IAudioPlayer & IVideoPlayer as generic instances - but even if I am - is it possible at all?
I can only see that it would work if IVideoPlayer allso inherited IMediaPlayer<ivideo>, but I cant do that since IAudioPlayer already inherites it? My head hurts.
public interface IMedia { }
public interface IAudio : IMedia { }
public interface IVideo : IAudio { }
public interface IMediaPlayer<T> where T : IMedia
{
T Media { get; }
}
public interface IAudioPlayer : IMediaPlayer<IAudio>
{
}
public interface IVideoPlayer : IAudioPlayer
{
}
|
|
|
|
|
What if you did something like...
public interface IVideoPlayer : IMediaPlayer<IVideo>, IAudio
{
}
Maybe there are some implementation details that IVideoPlayer needs from IAudioPlayer, I'm not sure.
|
|
|
|
|
I guess you ment IAudioPlayer?
IVideoPlayer would then have both Media as IAudio annd IVideo.
Ambiguity between 'IMediaPlayer<IVideo>.Media' and 'IMediaPlayer<IAudio>.Media'
|
|
|
|
|
Got it working. Without generic mess.
Thougt I tryed everything.
public interface _IMedia { }
public interface _IAudio : _IMedia { }
public interface _IVideo : _IAudio { }
public class CMedia : _IVideo
{
}
public interface _IMediaPlayer
{
_IMedia Media { get; }
}
public interface _IAudioPlayer : _IMediaPlayer
{
new _IAudio Media { get; }
}
public interface _IVideoPlayer : _IAudioPlayer
{
new _IVideo Media { get; }
}
public class _CMediaPlayer : _IMediaPlayer
{
private CMedia m_Media = new CMedia();
public _IMedia Media { get { return m_Media; } }
}
public class _CAudioPlayer : _CMediaPlayer, _IAudioPlayer
{
public new _IAudio Media { get { return base.Media as _IAudio; } }
}
public class CVideoPlayer : _CAudioPlayer, _IVideoPlayer
{
public new _IVideo Media { get { return base.Media as _IVideo; } }
}
|
|
|
|
|
Hm, what about the Liskov principle (see e.g. http://en.wikipedia.org/wiki/Liskov_substitution_principle[^])? Your example somehow reminds me of the square-and-rectangle issue there...
In case that the VideoPlayer can use some code of the AudioPlayer, I'd go for composition instead of inheritance.
|
|
|
|
|
Thanks. It's a good idea, but in my case it was more about hiding properties that isnt 'needed'. Player & Media is allways initzialed as video type.
|
|
|
|
|
Hi,
You could do it with generics in the following way:
public interface IMedia
{
}
public interface IAudio : IMedia
{
}
public interface IVideo : IAudio
{
}
public interface IMediaPlayer<T> where T : IMedia
{
T Media
{
get;
}
}
public interface IAudioPlayer<T> : IMediaPlayer<T> where T : IAudio
{
}
public interface IVideoPlayer<T> : IAudioPlayer<T> where T : IVideo
{
}
public class Class1
{
public void Example()
{
IVideoPlayer<IVideo> videoPlayer = null;
IAudioPlayer<IAudio> audioPlayer = null;
}
}
The problem is that your video player can't be compiled against IVideo and use an audio player compiled against IAudio. Your video player and audio player need to be compiled against the same type.
I don't know what this issue with generics is called, but I always find that generics bread more generics.
Kind Regards,
Keld Ølykke
|
|
|
|
|
Hi !
I need help with converting 24 bit input to 16 bit "on the fly" im trying to record audio output, if the format is set to 24 bit depth i have problem with mix it down to one channel (sound is slower) here is the example wchich im using to convert if audio has 32 bit i dont know how to change this code if input has 24 bit
byte[] newArray16Bit = new byte[e.BytesRecorded / 2];
short two;
float value;
for (int i = 0, j = 0; i < e.BytesRecorded; i += 4, j += 2)
{
value = (BitConverter.ToSingle(e.Buffer, i));
two = (short)(value * short.MaxValue);
newArray16Bit[j] = (byte)(two & 0xFF);
newArray16Bit[j + 1] = (byte)((two >> 8) & 0xFF);
}
byte[] mono = StereoToMono(newArray16Bit);
OutFile.Write(mono);
i found sample code to convert but it returns float[] i need byte:
public float[] Convert24BitToFloat(byte[] input)
{
int inputSamples = input.Length / 3;
float[] output = new float[inputSamples];
int outputIndex = 0;
var temp = new byte[4];
for(int n = 0; n < inputSamples; n++)
{
Array.Copy(input,n*3,temp,0,3);
int sample = BitConverter.ToInt32(temp,0);
output[outputIndex++] = sample / 16777216f;
}
return output;
}
|
|
|
|
|
Instead of calculating with bytes, go to the samples. Samples are 16bit ints, 24bit ints (which are not well represented in .Net), or 32bit floats. Then do your calculations on the samples. And then convert to the output format.
|
|
|
|
|
I'm given a string which contains an arbitrary amount of code. I want to calculate a number which represents the code complexity of that string. Something like:
int complexity = Lib.FindComplexity(someString);
I realize there are a lot of tools out there that will do this for you. These tools will not work for me, because I want to do it programmatically. I'd love for the library to be in C#, but will work with anything at this point.
Thanks in advance!
|
|
|
|
|
gastonbed wrote: Thanks in advance!
For what? Are you asking how to build this, or stuck with anything else?
The "parts" that build up code-complexity are described here[^]. You'd be writing code to do the same.
Bastard Programmer from Hell
If you can't read my code, try converting it here[^]
|
|
|
|
|