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 968227
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T02:26:41+00:00 2026-05-16T02:26:41+00:00

I wrote a serializer (to Byte Array) for dictionaries that have a string key,

  • 0

I wrote a serializer (to Byte Array) for dictionaries that have a string key, but an object of some sort as its value.

I’ve never implemented a generic type in a function or used a delegate before, so I’m a bit concerned about this being significantly slower than writing a serialization function for a specific type of Dictionary (Dictionary(Of String, MyClass) for example).

Should this code be significantly slower due to the use of the generic type or the delegate?

Public Delegate Function Serializer(Of T)(ByRef Obj As T) As Byte()

Function SerializeDictionary_String_Object(Of T)(ByRef D As Dictionary(Of String, T), ByVal S As Serializer(Of T)) As Byte()

    Dim OBJ As T

    For Each X In D
        OBJ = X.Value
        Exit For
    Next

    Return S(OBJ)

End Function

Here’s some code that uses this:

SerializeDictionary_String_Object(Of MyClass)(MyDictionary, AddressOf MyClass.Serialize)

It works, and I could loop it and compare it to a more static Dictionary serializer, but I’m more concerned about when I start using this for a lot of different String/Object dictionary combinations, and it’ll take me a long time to write a bunch of static dictionary serializers (that’s what I’m hoping to avoid in the first place)

edit: simplified intro text

  • 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-16T02:26:42+00:00Added an answer on May 16, 2026 at 2:26 am

    No, generics were specifically designed to make code faster. Just as fast as hard-coding the types. Quicker than the alternative, using Object, since you can avoid boxing value types and don’t have to cast.

    A delegate call is slower than a direct method call. But it is still very, very fast. You’d have to call it a billion times to notice the difference.

    Are you aware of the BinaryFormatter class? It already does this.

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

Sidebar

Related Questions

I want to write an object into a stream (or byte array) with its
I have an object model called MyObject that I'm serializing to a json string
We have some code that looks like this: class Serializer { public: template<class Type>
I have to send a byte array (encoded photo) from my PHP client to
I am trying to convert an object to byte array & send it through
Lets say I have some domain objects that will need to be serialized/packed using
I having some issues with converting a large byte[] array into a strongly typed
I am trying to write an object to an Xml string and take that
I know of at least two byte-code enhancer that modify the object model at
I want to store a 4-byte int in a char array... such that the

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.