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

  • Home
  • SEARCH
  • 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 8792103
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T22:56:02+00:00 2026-06-13T22:56:02+00:00

I am working on a project where I need to convert C++ code to

  • 0

I am working on a project where I need to convert C++ code to C#.

I came across _bstr_t in the code I would like to know how the equivalent in C#.

  • 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-06-13T22:56:03+00:00Added an answer on June 13, 2026 at 10:56 pm

    The _bstr_t class is a wrapper for the BSTR type. This is a string in OLE Automation that is standardized across languages.

    That said, the equivalent type in .NET is a System.String.

    The key is when interacting with it (or defining your interfaces for COM interop in .NET code), you’ll want to use the MarshalAsAttribute with a value from the UnmanagedType enumeration of UnmanagedType.BStr, like so:

    // This is on an interface that is in unmanaged code.
    public void DoSomething([MarshalAs(UnmanagedType.BStr] string myString);
    

    Note that if your class is actually exposing the _bstr_t in a COM interface, then you should change it to expose a BSTR; _bstr_t is a helper class that isn’t meant to be exposed across interface boundaries. The BSTR is for that and the methods on _bstr_t are for handling the allocation and use of BSTR instances.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I working on an intranet project for IE6 (i know...) and I need to
I am working on a migration project and need to convert following Oracle query
I am recently working in a project. There I need to convert language from
I am working on a project, and I need something like office web app
I'm working in a project that need to get SVD (Single Values Decomposition) for
I was working on a project and I need to read a row in
I am working on a project where I need to automate some workflows in
I am working on a project and I need to save user configuration. The
I am working on this project where I need to read in a lot
I'm working on a project where I need to get the total row count

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.