using

header files and using namespace ...

Someone once hinted that doing this in a header file is not advised: using namespace std; Why is it not advised? ...

Java equivalent of C# 'using' statement

I'm transitioning from C# to java, so please bear with me... When reading a file in C#, you simply wrap it all in a big 'using' block, so that if you have an exception, the file will still be closed. Like so (maybe inaccurate but you get the idea): using(FileStream fs = new FileStream("c:\\myfile.txt")) { // Any exceptions while read...

i want to adding "xmlns" attribute in xml file using xslt

I want to following xml file output: <?xml version="1.0" encoding="ISO-8859-1" ?> - <T0020 xsi:schemaLocation="http://www.safersys.org/namespaces/T0020V1 T0020V1.xsd" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://www.safersys.org/namespaces/T0020V1"&gt; - <INTERFACE> <NAME>SAFER</NAME> <VERSION>04.02</VERSION...

Nested using statements in VB.Net

As Eric Gunnerson shows in this blog post, in C# you can nest using statements as: using (StreamWriter w1 = File.CreateText("W1")) using (StreamWriter w2 = File.CreateText("W2")) { // code here } Is there a similar way to do it in VB.Net? I want to avoid too many indentation levels. ...

How big is performance decrease of compiling when there are not necessary USINGs?

Hi, I'm just curious if unnecessary USINGs in my code slows down compiling of Visual Studio solution. Over time there are new and new usings in my code because of changes in code when some features are added, reimplemented and sometimes removed. Should I even care about the number of USINGs? How can I remove unnecessary USINGs? Thanks...

Determine if code called from an exception handler (using statement)?

I want to do something mildly silly. In my Dispose() method for an object, I want to print a debug trace for the object, telling me all events which happened while it was alive. But as this takes time and money, I only want to do this if Dispose() is being called because an exception was thrown. So I would like to do if (exceptionIsC...

Difference between "using MyNameSpace;" and "namespace MyNameSpace"

Hello I am new to asp.net. I am confused what is the difference between "using MyNameSpace;" and "namespace MyNameSpace". My demo code is as follow... using System; using System.Collections.Generic; using System.Linq; using System.Web; using System.Web.UI; using System.Web.UI.WebControls; using MyNameSpace; namespace MyNameSpa...

Using the "Using" Statement with Typed Dataset Table Adapters

Simple Question. Is it important to use the using statement when working with typed dataset table adapters? Most examples I have seen on the net never use the using statement. using (Data_ItemTableAdapter adapter = new Data_ItemTableAdapter()) { DataItemTable = a.GetDataByDataItemID(DataItemID); // more code here } Thanks...

CXF DOSGI Discovery using Zookeeper

Hi, I am trying to use CXF Distributed OSGi Discovery for my project and I followed all the steps in the link http://cxf.apache.org/dosgi-discovery.html. I could see on the zookeeper server console that my cxf bundle has initaited the connection. But ,when I deploy bundles with remote services, it doesn't show up on zookeeper server con...

How to sort an XMl using XSLT 1.0?

I'm looking for an XSL to sort and group an XML by a node and sum by another node. I will have to use XSLT 1.0. Here is my XML. After sorting I need to have a new XML sorted and Grouped by <TransCode>, and all <TransAmt> should be summed for each group. I'm looking for the XSL for this task. Any help is appreciated. After sorting n...

Using the ndisprot example driver (in the WDK) with C++

Hey all, I have compiled succesfully the ndisprot example ndis driver that came with the Windows Driver Kit, but I don't know how to use it from C++ to send or receive packets. Could someone instruct me on how? ...

what is the expected behavior?

Below is a purely academically invented class hierarchy. struct X{ void f1(); void f2(); void f3(); }; struct Y : private X{ void f4(); }; struct Z : X{ }; struct D : Y, Z{ using X::f2; using Z::X::f3; }; int main(){} I expected using declaration for X::f2 to be ambiguous as 'X' is a...

Attaching a process to an Event Handler in Visual Studio 2010 for Sharepoint 2010 site

Hi Guys, I've written an event handler for sharepoint 2010 site using visual studio 2010 . I had attached a breakpoint to the code and followed the process which i had done in visual studio 2008. It is to use the Attach to process option and select the w3wp option. The event gets attached but the breakpoint is not firing. I ve check...

Is there a way to group "using" statements in a separate file?

Say you have some boiler plate using statements. Say something like this: #if !NUNIT using Microsoft.VisualStudio.TestTools.UnitTesting; using Category = Microsoft.VisualStudio.TestTools.UnitTesting.DescriptionAttribute; #else using NUnit.Framework; using TestClass = NUnit.Framework.TestFixtureAttribute; using TestMethod = NUnit.Framew...

CA2000 error with 'using' statement. How to make this valid?

The following code is giving me this code analysis error CA2000 : Microsoft.Reliability : In method 'SessionSummary.SessionSummary_Load(object, EventArgs)', call System.IDisposable.Dispose on object 'entities' before all references to it are out of scope. I am using a 'using' statement, so I am surprised on this: private v...

Which is faster - A Using block or Try/Catch/Finally

This is a followup question to this Should I stick with the Try/Catch/Finally construct, or go with the Using construct? Sample Code for Try/Catch/Finally: Dim oRequest As WebRequest Dim oResponse As HttpWebResponse = Nothing Dim dataStream As Stream = Nothing Dim reader As StreamReader = Nothing Dim responseFromServer As String Try ...

c# using declarations - more = good or bad?

edit typos Hi, This is possibly a moronic question, but if it helps me follow best practice I don't care :P Say I want to use classes & methods within the System.Data namespace... and also the System.Data.SqlClient namespace. Is it better to pull both into play or just the parent, ie... using System.Data using System.Data.SqlClient...

using in defining object in c#

hi friends,when we use using for defining an object?for example: using (Login objLogin = new Login()) i know that we use when we want to clean the memory after using this object but i dont know when should we clean the memory. ...

Using alias with 'using'

I would like to define my own alias for complex type. I'm curious why the compiler does not recognize already imported types. For example: Works: using System; using System.Collections.Generic; using myCollection = System.Collections.Generic.List <System.Collections.Generic.Dictionary<string, string>>; Error: us...

php htaccess redirect

hi to all, i have a site in php. now i want to redirect my older site url to new url. whenever user enter my old site url in address bar using browser url must be redirect to my new url. How can i do this using .htaccess file. Thanks in advance. ...