|
i need a real example where we need to build an interface.
i mean why we need it at all?? its confusing me.
once i implemented the IComparable interface, but did not understand why !!!
thank you all
When you get mad...THINK twice that the only advice
Tamimi - Code
|
|
|
|
|
An interface is used to specify that a class supports a special behaviour. That way you can make one of your classes support some behaviour that some other class requires.
For example, the Array.Sort method can take a reference to a class that implements the IComparer interface. That way you can create your own comparer and feed to the Sort method, and the Sort method can use the methods specified in the interface without caring what the actual class of the object is.
---
b { font-weight: normal; }
|
|
|
|
|
what is confusing me that we can do all the job needed without
implementing any interface, right ??
its seem to be an orginsation tool to do sometiong(excuse me Stupidity )
When you get mad...THINK twice that the only advice
Tamimi - Code
|
|
|
|
|
Yes, of course you can do everything without using interfaces, but sometimes the way around them would be quite long.
Almost everything in a programming language are different ways of doing similar things. The for keyword for example is totally superflous, as it's only a variation of a while loop. You could write an entire program by using only if and goto , but the code would of course be terrible.
The only programming language that I know of that lacks any superflous commands is the language Brainfuck. The entire language consists of eight instructions.
---
b { font-weight: normal; }
|
|
|
|
|
thank you man, that was very Helpful
When you get mad...THINK twice that the only advice
Tamimi - Code
|
|
|
|
|
|
|
I want to play a movie not from start
ie. lets say the movie is of 40 seconds I want to play from the 15th second.
so what to do.
please help
Rabindra Patra
|
|
|
|
|
What are you using to play it ? WMP and DX both allow you to specify the starting location.
Christian Graus - C++ MVP
|
|
|
|
|
Hi, is there some way for me to play music in C#? I don't know how to do this and web resources are fairly limited. I would appreciate much help. Thanks!
|
|
|
|
|
u can use DirectShow for this...
Thanks & Regards,
Pramod
"Everyone is a genius at least once a year"
|
|
|
|
|
do you perchance have a code snippet for this? I have no clue whatsoever..thanks very much!
|
|
|
|
|
edel_ong wrote: web resources are fairly limited.
No. No, they aren't. Both DirectX and the Windows Media Player APIs are widely documented, and there's at least one C# mp3 player on this site.
Christian Graus - C++ MVP
|
|
|
|
|
Hi all,
I am trying to change code and recompile dll's of a C#.Net class library.
But even before i change any thing i am getting this error:
A failure occurred while attempting to start the compilation.
Please help me..
Thanks in anticipation.
Kris.
If you fail for the first time , call it version 1.0.
|
|
|
|
|
Might a file be read only that needs to be writable ?
Christian Graus - C++ MVP
|
|
|
|
|
after i look msdn, i know
opE1.sheetObj.Copy(nul, nul);
but, not create new workbook?
why? how to copy a sheet to another workbook?
(use c# (office lib),not vba)
|
|
|
|
|
my com (use c# and localserver) implement the interface ITest
[Guid("39c13a4d-011e-11d0-9675-0020afd8adb3")]
[InterfaceTypeAttribute(ComInterfaceType.InterfaceIsIUnknown)]
ITest
{
void fuc0( ref System.Guid riid, [MarshalAs(UnmanagedType.Interface)]out object ppvObject);
void fuc1(ref System.Guid riid, [MarshalAs(UnmanagedType.IUnknown)]out object ppUnk);
void fuc2();
}
public CTest:ITest
{
void fuc0( ref System.Guid riid,out object ppvObject)
{
ppvObject = this;
}
void fuc1(ref System.Guid riid,out object ppUnk)
{
IntPtr pSite = IntPtr.Zero;
IntPtr pUnk = Marshal.GetIUnknownForObject(this);
Marshal.QueryInterface(pUnk, ref riid, out pSite);
Marshal.Release(pUnk);
Marshal.Release(pUnk);
ppUnk = pSite;
//ppUnk= this;
}
void fuc2()
{
MessageBox.Show("fuc2 ok");
}
C++ calls
ITest:IUnknown
{
HRESULT fuc0(REFIID riid, LPVOID* ppvObject);
HRESULT fuc1(REFIID riid, LPUNKNOWN *ppUnk);
HRESULT fuc2();
}
fuc0 's param riid = IDD_ITest ,return OK,
fuc1's param riid = IDD_IUnknown,return 0xc0000005,ppUnk == NULL;
fuc2 return ok。
have many try,i find if the param is "LPUNKNOWN *ppUnk " will return 0xc0000005.
if i regist for InprocServer will have not these problem.
help please
|
|
|
|
|
Hi everyone
I have been asked to create a dashboard for tracking sells of a company and thier preformace. there are two things that has complicated the matters. one that it has to use directx for the Texture of the pictures and it has to be a executive dashboard using C#.
I was not able to find any material on executive dashboard let alone one with Directx.
if someone can help me out here, it would be great
|
|
|
|
|
homer simpsom wrote: I was not able to find any material on executive dashboard
Well, that's just a terminology. They just want a windows app
Why does it need DX ? That seems silly to me.
Christian Graus - C++ MVP
|
|
|
|
|
Well that is excally the problem.
I am just wondering as how one would create a normal Dashboard. there are not that many material on that.
even a widget would be fine at this point but there are not many sources for that nither on C#
|
|
|
|
|
What is a dashboard ?
Christian Graus - C++ MVP
|
|
|
|
|
I did some work for a client that used Dundas for the exact same thing.
|
|
|
|
|
Hi
Im working on socket connection.
client will send data to the server at some regular intervals.
how the client can identify if the ethernet cable is unplugged (client has to show some message "cable disconnected". if cable is plugged again. It should detect it automatically has to continue the task again.
Please give ur answers with some sample code/link
Thanks and Regards,
Srini
|
|
|
|
|
The recommended way to do this with V2.0 of the framework is to use the System.Net.NetworkInformation namespace.. This sample should get you started:
public class NetInfoTest<br />
<br />
{<br />
public static void Main()<br />
<br />
{<br />
try<br />
<br />
{<br />
DumpIPAddresses();<br />
<br />
NetworkChange.NetworkAvailabilityChanged += OnNetworkAvailabilityChanged;<br />
<br />
NetworkChange.NetworkAddressChanged += OnNetworkAddressChanged;<br />
<br />
Console.ReadLine();<br />
}<br />
<br />
catch (Exception e)<br />
<br />
{<br />
Console.WriteLine(e);<br />
}<br />
<br />
finally<br />
<br />
{<br />
Console.ForegroundColor = ConsoleColor.Green;<br />
<br />
Console.BackgroundColor = ConsoleColor.Black;<br />
}<br />
}<br />
<br />
<br />
public static void OnNetworkAvailabilityChanged(object sender, NetworkAvailabilityEventArgs e)<br />
<br />
{<br />
if (e.IsAvailable)<br />
<br />
{<br />
Console.ForegroundColor = ConsoleColor.Green;<br />
<br />
Console.WriteLine("Network Available");<br />
}<br />
<br />
else<br />
<br />
{<br />
Console.ForegroundColor = ConsoleColor.Red;<br />
<br />
Console.WriteLine("Network *NOT* Available");<br />
}<br />
}<br />
<br />
public static void OnNetworkAddressChanged(object sender, EventArgs e)<br />
<br />
{<br />
Console.ForegroundColor = ConsoleColor.Red;<br />
<br />
Console.BackgroundColor = ConsoleColor.Yellow;<br />
<br />
Console.WriteLine("Address change event at {0}", DateTime.Now.ToString());<br />
<br />
Console.ForegroundColor = ConsoleColor.Green;<br />
<br />
Console.BackgroundColor = ConsoleColor.Black;<br />
<br />
DumpIPAddresses();<br />
}<br />
<br />
public static void DumpIPAddresses()<br />
<br />
{<br />
<br />
NetworkInterface[] NetworkInterfaces = NetworkInterface.GetAllNetworkInterfaces();<br />
<br />
<br />
foreach (NetworkInterface NI in NetworkInterfaces)<br />
<br />
{<br />
<br />
if (NI.NetworkInterfaceType == NetworkInterfaceType.Ethernet)<br />
<br />
{<br />
Console.WriteLine(Environment.NewLine);<br />
<br />
Console.WriteLine(Environment.NewLine);<br />
<br />
<br />
Console.WriteLine(NI.Name + " " + NI.Description);<br />
<br />
Console.WriteLine("-------------------------------------------------");<br />
<br />
<br />
IPInterfaceProperties IPProps = NI.GetIPProperties();<br />
<br />
<br />
UnicastIPAddressInformationCollection UnicastAddresses = IPProps.UnicastAddresses;<br />
<br />
foreach (UnicastIPAddressInformation uaddr in UnicastAddresses)<br />
<br />
{<br />
<br />
if (uaddr.Address.AddressFamily == AddressFamily.InterNetwork)<br />
<br />
Console.WriteLine("\t" + uaddr.Address.ToString());<br />
}<br />
}<br />
}<br />
}<br />
}<br />
Keep in mind availability here is based on the state of the network adapter. This does not tell you the reach of your connection (ie. connected to the internet, a managed network, etc)
You can use "NetworkAvailabilityChanged" and "NetworkAddressChanged" events, for reconnect operation.
Thanks Mike Flasko for code example;)
|
|
|
|
|
Hello everyone!
I have a C# project on a MS card, since hard drives suck...
But I don't have enough space for the big .PDB files, so where's the setting to change the path? Thanks!
Windows Calculator told me I will die at 28.
|
|
|
|