|
thanks man
first one gives the result as i wished..but i didnt get the point what was my mistake
|
|
|
|
|
How about the second one, it should give the same result (right?)
Your mistake is that you search for the first space, you could fix it be adding ,i (yes that's all) to the call to IndexOf - but then it will still suck and I really recommend my second version (or the build-in function)
|
|
|
|
|
no man the second one didnt give the same result..it doesnt make capital first letter of first word...and where should i add the "i" ?? i used like
if ((i == 0) || (i == text.IndexOf[i](" ")+ 1))
and
if ((i == 0) || (i == text.IndexOf(" ")[i]+ 1))
but it given error
modified on Thursday, January 7, 2010 9:27 AM
|
|
|
|
|
if ((i == 0) || (i == text.IndexOf(" ", i)+ 1))
Well I said ,i , not [i]
|
|
|
|
|
I tested my second function, it works fine
edit: to be fair, when I first posted it it had a bug that made the first letter lower case, it was just that it said bool nextIsCap = false which obviously should have been true (but hey that's no reason to just forget about that function, it's a very simple fix and I fixed it the next minute or so)
|
|
|
|
|
thanks man i am really appreciated because of your help..
take care and thanks again
but my method doesnt work again even if write "i" as u said
|
|
|
|
|
You're welcome
|
|
|
|
|
You should use the method supplied by the .NET Framework called TextInfo.ToTitleCase() ; it's in the System.Globalization namespace, the easiest way to acquire the TextInfo object is to retrieve it from the CurrentCulture like so:
System.Globalization.CultureInfo.CurrentCulture.TextInfo.ToTitleCase("mert efe");
MSDN Reference: http://msdn.microsoft.com/en-us/library/system.globalization.textinfo.totitlecase.aspx[^]
Hold on a second here... Don't you think you might be putting the horse ahead of the cart?
|
|
|
|
|
hii Ben
thanks for you reply..i tried the method u suggested it is really good method..but i want to ask one more question about it...for example we have capital i like "İ" in turkish but it writes like I when it makes it capital..i think it is because of
TextInfo myTI = new CultureInfo("en-US",false).TextInfo;
so how i can use turkish characters instead of english ?
|
|
|
|
|
erdinc27,
You'll need to get the code letters for the Turkish culture, I'm not sure what they are but you should be able to find them rather quickly by searching the 'Net. Once you have those code letters you'll replace the "en-US" code with the Turkish code, then it will operate on the string using the Turkish alphabet.
Hold on a second here... Don't you think you might be putting the horse ahead of the cart?
|
|
|
|
|
Does the IPv6 protocol deal with UDP datagrams ???
|
|
|
|
|
|
The IPv6 protocol only deals with IPv6 packets - which might happen to contain an UDP datagram, or not. It doesn't care, it just sends a bunch of bytes, it's up to Transport Layer and above to make sense of it.
|
|
|
|
|
Hi all...
As calling an 'ipAddress' from class 'Sockaddr' to find the local IP address of my PC, it always return an IP address 255.255.255.255 for IPv4, and ffff.ffff.ffff.ffff for IPv6.
the class 'Sockaddr' belongs to 'SharpPcap-2.1.1', the implementation of the class is as follwo:
using System;
using System.Runtime.InteropServices;
using System.Net.NetworkInformation;
namespace SharpPcap.Containers
{
public class Sockaddr
{
public enum Type
{
AF_INET_AF_INET6,
HARDWARE,
UNKNOWN
}
public Type type;
static public System.Net.IPAddress ipAddress; // if type == AF_INET_AF_INET6
public PhysicalAddress hardwareAddress; // if type == HARDWARE
private int _sa_family;
public int sa_family
{
get { return _sa_family; }
}
public Sockaddr(PhysicalAddress hardwareAddress)
{
this.type = Type.HARDWARE;
this.hardwareAddress = hardwareAddress;
}
public Sockaddr(IntPtr sockaddrPtr)
{
// A sockaddr struct. We use this to determine the address family
PcapUnmanagedStructures.sockaddr saddr;
// Marshal memory pointer into a struct
saddr = (PcapUnmanagedStructures.sockaddr)Marshal.PtrToStructure(sockaddrPtr,
typeof(PcapUnmanagedStructures.sockaddr));
// record the sa_family for informational purposes
_sa_family = saddr.sa_family;
byte[] addressBytes;
if(saddr.sa_family == Pcap.AF_INET)
{
type = Type.AF_INET_AF_INET6;
PcapUnmanagedStructures.sockaddr_in saddr_in =
(PcapUnmanagedStructures.sockaddr_in)Marshal.PtrToStructure(sockaddrPtr,
typeof(PcapUnmanagedStructures.sockaddr_in));
ipAddress = new System.Net.IPAddress(saddr_in.sin_addr.s_addr);
} else if(saddr.sa_family == Pcap.AF_INET6)
{
type = Type.AF_INET_AF_INET6;
addressBytes = new byte[16];
PcapUnmanagedStructures.sockaddr_in6 sin6 =
(PcapUnmanagedStructures.sockaddr_in6)Marshal.PtrToStructure(sockaddrPtr,
typeof(PcapUnmanagedStructures.sockaddr_in6));
Array.Copy(sin6.sin6_addr, addressBytes, addressBytes.Length);
ipAddress = new System.Net.IPAddress(addressBytes);
} else if(saddr.sa_family == Pcap.AF_PACKET)
{
type = Type.HARDWARE;
PcapUnmanagedStructures.sockaddr_ll saddr_ll =
(PcapUnmanagedStructures.sockaddr_ll)Marshal.PtrToStructure(sockaddrPtr,
typeof(PcapUnmanagedStructures.sockaddr_ll));
byte[] hardwareAddressBytes = new byte[saddr_ll.sll_halen];
for(int x = 0; x < saddr_ll.sll_halen; x++)
{
hardwareAddressBytes[x] = saddr_ll.sll_addr[x];
}
hardwareAddress = new PhysicalAddress(hardwareAddressBytes); // copy into the PhysicalAddress class
} else
{
type = Type.UNKNOWN;
// place the sockaddr.sa_data into the hardware address just in case
// someone wants access to the bytes
byte[] hardwareAddressBytes = new byte[saddr.sa_data.Length];
for(int x = 0; x < saddr.sa_data.Length; x++)
{
hardwareAddressBytes[x] = saddr.sa_data[x];
}
hardwareAddress = new PhysicalAddress(hardwareAddressBytes);
}
}
}
}
Do anyone can help me ???
Thanks.................
|
|
|
|
|
Hi,
your code seems a bit complicated. Did you know that there is some framework implementation to obtain the local ip-adress?
Check out this article:
How To Get IP Address Of A Machine[^]
Hope this helps.
Regards
Sebastian
|
|
|
|
|
Hi Sebastian,
such techniques return the local IP address, i.e. the address is valid on the LAN, but in general not on the internet. To get the "external" IP address, one really needs an external web service, and I happen to offer one here: http://www.perceler.com/tools1.php[^].
|
|
|
|
|
Hi all,
Any idea how to handle an C# event in a Excel?
eg. invoke Excel action with a C# timer event.
(I can article "C# handle Excel's event" but not "C# event in Excel")
thank you!
Jim
|
|
|
|
|
You're going to have to explain what you mean and which "event" and how this code is setup. Are you using the Excel Object Model in your C# code?? Or did you write an application in C$ that Excel is running through a Shell statement, or something similar??
|
|
|
|
|
I am not sure about the Excel Object Model.
I want to have a C# library I can call a C# function, which i have done with help of below article.
http://blogs.msdn.com/eric_carter/archive/2004/12/01/273127.aspx
I also want to have setup callback, event in the C# space and i can get the callback/event inside Excel.
eg. i have an event like below, i can get the event with AlarmEventHandler. I just want to have such event happening in Excel.
(below code copied from msdn)
public class AlarmClock
{
public event AlarmEventHandler Alarm;
protected virtual void OnAlarm(AlarmEventArgs e)
{
if (Alarm != null)
{
Alarm(this, e);
}
}
}
public static void Main (string[] args)
{
WakeMeUp w= new WakeMeUp();
AlarmClock clock = new AlarmClock();
<big> clock.Alarm += new AlarmEventHandler(w.AlarmRang);</big>
clock.Start();
}
|
|
|
|
|
Yes, you can do this. Go read MSDN articles about Office Interop and you'll soon be able to do this and much more - as long as your code only needs to work with the later incarnations of Office.
|
|
|
|
|
Hi all,
can any one please tell me how can i read from a file which resides in net work drive?
Regards
Lijo
|
|
|
|
|
As a usual file (e.g. System.IO.File.ReadAllText(...) ) Doesn't it work?
|
|
|
|
|
my file resides in remote system. from that system only i want to read a file. can you please tell me how can i do that?
Regards
Lijo
|
|
|
|
|
This can be done in 3 ways:
1. Map the remote drive (this means, assing e.g. Z: letter to the drive)
2. Read from this location: \\remote-computer\Share\path\file.txt . In this case, the file must be shared in Share folder on the remote computer.
3. If you are running under the credentials of the administrator on the remote computer (this means that two computers are in the same domain), you can read directly from this path: \\remote-computer\C$\path\file.txt .
|
|
|
|
|
Please see also my answer in this thread on CodeProject: [^]
|
|
|
|