C
C# Learner
Is there a nicer way to write the following?
private static bool TryWriteToStream(NetworkStream ns, byte[] bytes,
int size)
{
bool result = true;
try {
ns.Write(bytes, 0, size);
} catch {
result = false;
}
return result;
}
I mean - is there a way of determining failure/success of writing to
the NetworkStream, without having to rely on an exception being raised
to indicate failure?
private static bool TryWriteToStream(NetworkStream ns, byte[] bytes,
int size)
{
bool result = true;
try {
ns.Write(bytes, 0, size);
} catch {
result = false;
}
return result;
}
I mean - is there a way of determining failure/success of writing to
the NetworkStream, without having to rely on an exception being raised
to indicate failure?