Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 971923
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T03:02:29+00:00 2026-05-16T03:02:29+00:00

I am using .NET 3.5. I am creating a simple class and wants to

  • 0

I am using .NET 3.5. I am creating a simple class and wants to make sure that the class after processing should not be null or should not be a new too..

So if we can just Test it like that

Dim objClass as new Class()

' do some processing with the class '
' and then.. check that if this object returned is not empty '

If (objClass = Class.Empty) Then
//Do stuff
Else
//Do Other Stuff
End If

is there a way we can create this empty Field like we have in String.Empty?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-16T03:02:30+00:00Added an answer on May 16, 2026 at 3:02 am

    But in your example the class isn’t technically empty. You’ve created an instance of Class using the default constructor. Who knows, the default constructor may have initialised over 10MB of string content. What your code is technically checking is, is the class equal to it’s default state just after being constructed.

    See this for example of VB constructors and what is happening.

    If you correctly implemented CompareTo(…) you could call

    If (objClass.CompareTo(new Class()) == 0) Then 
     //Do stuff 
    Else
     //Do Other Stuff 
    End If 
    

    But that would seem overkill / expensive, but the only way it would work.

    Another option would be: (sorry c# based example)

    Interface IEmpyClass
    {
       bool IsEmptyClass{get;}
    }
    
    public class Class : IEmptyClass
    {
       public bool IsEmptyClass{get; private set;}
    
       public Class()
       {
         IsEmptyClass = true;
       }
    
       public void DoSomething()
       {
           // Do something
           IsEmptyClass = false;
       }
    }
    

    You would be responsible for implementing the example and changing the property when the class state changed from “empty”, but that would be quicker in code, etc. and could cope when clases have constructors with members. It could be checked just with

    If (objClass.IsEmptyClass) Then 
     //Do stuff 
    Else
     //Do Other Stuff 
    End If 
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Using .NET and the Word Interop I am programmatically creating a new Word doc
I am creating a website using ASP.NET that supports multiple languages. For that I
I'm creating a database application using ASP.NET and I want to make a Windows
I tried creating a simple HTTP server using System.Net.HTTPListener, but it doesn't receive connections
I am creating a simple console Application in .Net to create a New Account
RuNubie here. I've got a class Login that logs into gmail using the net/IMAP
I'm creating a basic web service in asp.net/c# using simple ASMX services. When I
Am facing a problem, while creating components through TOM API using .NET/COM Interop. Actual
I am creating a web api using asp.net mvc4 and the response output is
I am creating a windows application using VB.Net and this application will take a

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.